Ticket #1476: register.patch
File register.patch, 41.7 KB (added by , 14 years ago) |
---|
-
bbp-includes/bbp-general-functions.php
115 115 116 116 /** 117 117 * The plugin version of bbPress comes with two topic display options: 118 * ~ Traditional -Topics are included in the reply loop (default)119 * ~ New Style -Topics appear as "lead" posts, ahead of replies118 * - Traditional: Topics are included in the reply loop (default) 119 * - New Style: Topics appear as "lead" posts, ahead of replies 120 120 * 121 121 * @since bbPress (r2954) 122 122 * 123 * @global obj $bbp124 123 * @param $show_lead Optional. Default false 125 * @return bool 124 * @return bool Yes if the topic appears as a lead, otherwise false 126 125 */ 127 126 function bbp_show_lead_topic( $show_lead = false ) { 128 127 return apply_filters( 'bbp_show_lead_topic', (bool) $show_lead ); … … 157 156 /** 158 157 * Append 'view=all' to query string if it's already there from referer 159 158 * 160 * @param string $original_link 161 * @return <type> 159 * @param string $original_link Original Link to be modified 160 * @uses current_user_can() To check if the current user can moderate 161 * @uses add_query_arg() To add args to the url 162 * @uses apply_filters() Calls 'bbp_add_view_all' with the link and original link 163 * @return string The link with 'view=all' appended if necessary 162 164 */ 163 165 function bbp_add_view_all( $original_link ) { 164 166 … … 201 203 * 202 204 * @param array $data Post data 203 205 * @param array $postarr Original post array (includes post id) 206 * @uses bbp_get_topic_post_type() To get the topic post type 207 * @uses bbp_get_reply_post_type() To get the reply post type 204 208 * @uses bbp_is_topic_anonymous() To check if the topic is by an anonymous user 205 209 * @uses bbp_is_reply_anonymous() To check if the reply is by an anonymous user 206 210 * @return array Data … … 258 262 * - count_tags: Count tags? If set to false, empty tags are also not counted 259 263 * - count_empty_tags: Count empty tags? 260 264 * @uses bbp_count_users() To count the number of registered users 265 * @uses bbp_get_forum_post_type() To get the forum post type 266 * @uses bbp_get_topic_post_type() To get the topic post type 267 * @uses bbp_get_reply_post_type() To get the reply post type 261 268 * @uses wp_count_posts() To count the number of forums, topics and replies 262 269 * @uses wp_count_terms() To count the number of topic tags 263 270 * @uses current_user_can() To check if the user is capable of doing things … … 536 543 537 544 // Assign variables 538 545 $defaults = array ( 539 'bbp_anonymous_name' => $_POST['bbp_anonymous_name'],540 'bbp_anonymous_email' => $_POST['bbp_anonymous_email'],541 'bbp_anonymous_website' => $_POST['bbp_anonymous_website'],542 'bbp_anonymous_ip' => $_SERVER['REMOTE_ADDR']546 'bbp_anonymous_name' => isset( $_POST['bbp_anonymous_name'] ) ? $_POST['bbp_anonymous_name'] : false, 547 'bbp_anonymous_email' => isset( $_POST['bbp_anonymous_email'] ) ? $_POST['bbp_anonymous_email'] : false, 548 'bbp_anonymous_website' => isset( $_POST['bbp_anonymous_website'] ) ? $_POST['bbp_anonymous_website'] : false, 549 'bbp_anonymous_ip' => isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : false 543 550 ); 544 551 545 552 $r = wp_parse_args( $args, $defaults ); … … 679 686 * @since bbPress (r2753) 680 687 * 681 688 * @uses bbp_is_user_profile_page() To check if it's a profile page 689 * @uses apply_filters() Calls 'bbp_profile_templates' with the profile 690 * templates array 682 691 * @uses bbp_is_user_profile_edit() To check if it's a profile edit page 692 * @uses apply_filters() Calls 'bbp_profile_edit_templates' with the profile 693 * edit templates array 694 * @uses bbp_is_view() To check if it's a view page 695 * @uses bbp_get_view_id() To get the view id 696 * @uses apply_filters() Calls 'bbp_view_templates' with the view templates array 683 697 * @uses bbp_is_topic_edit() To check if it's a topic edit page 698 * @uses bbp_get_topic_post_type() To get the topic post type 699 * @uses apply_filters() Calls 'bbp_topic_edit_templates' with the topic edit 700 * templates array 684 701 * @uses bbp_is_reply_edit() To check if it's a reply edit page 702 * @uses bbp_get_reply_post_type() To get the reply post type 703 * @uses apply_filters() Calls 'bbp_reply_edit_templates' with the reply edit 704 * templates array 685 705 * @uses apply_filters() Calls 'bbp_custom_template' with the template array 686 706 * @uses bbp_load_template() To load the template 687 707 */ … … 706 726 'forums/user-edit.php', 707 727 'bbpress/user-edit.php', 708 728 'user-edit.php', 729 'forums/user.php', 709 730 'bbpress/user.php', 710 731 'user.php', 711 732 'author.php', … … 716 737 } elseif ( bbp_is_view() ) { 717 738 $template = apply_filters( 'bbp_view_templates', array( 718 739 'forums/view-' . bbp_get_view_id(), 740 'bbpress/view-' . bbp_get_view_id(), 719 741 'forums/view.php', 720 'bbpress/view-' . bbp_get_view_id(),721 742 'bbpress/view.php', 722 743 'view-' . bbp_get_view_id(), 723 744 'view.php', … … 728 749 } elseif ( bbp_is_topic_edit() ) { 729 750 $template = array( 730 751 'forums/action-edit.php', 752 'bbpress/action-edit.php', 731 753 'forums/single-' . bbp_get_topic_post_type(), 732 'bbpress/action-edit.php',733 754 'bbpress/single-' . bbp_get_topic_post_type(), 734 755 'action-bbp-edit.php', 735 756 'single-' . bbp_get_topic_post_type(), … … 739 760 740 761 // Add split/merge to front of array if present in _GET 741 762 if ( !empty( $_GET['action'] ) && in_array( $_GET['action'], array( 'merge', 'split' ) ) ) { 742 array_unshift( $template, array(763 array_unshift( $template, 743 764 'forums/action-split-merge.php', 744 765 'bbpress/action-split-merge.php', 745 'action- bbp-split-merge.php'746 ) );766 'action-split-merge.php' 767 ); 747 768 } 748 769 749 770 $template = apply_filters( 'bbp_topic_edit_templates', $template ); … … 752 773 } elseif ( bbp_is_reply_edit() ) { 753 774 $template = apply_filters( 'bbp_reply_edit_templates', array( 754 775 'forums/action-edit.php', 776 'bbpress/action-edit.php', 755 777 'forums/single-' . bbp_get_reply_post_type(), 756 'bbpress/action-edit.php',757 778 'bbpress/single-' . bbp_get_reply_post_type(), 758 779 'action-bbp-edit.php', 759 780 'single-' . bbp_get_reply_post_type(), … … 810 831 * @since bbPress (r2688) 811 832 * 812 833 * @uses get_query_var() To get {@link WP_Query} query var 834 * @uses is_email() To check if the string is an email 835 * @uses get_user_by() To try to get the user by email and nicename 813 836 * @uses WP_User to get the user data 814 837 * @uses WP_Query::set_404() To set a 404 status 815 * @uses is_multisite() To check if it's a multisite816 838 * @uses current_user_can() To check if the current user can edit the user 817 839 * @uses apply_filters() Calls 'enable_edit_any_user_configuration' with true 818 840 * @uses wp_die() To die 841 * @uses bbp_get_query_name() To get the query name and check if it's 'bbp_widget' 842 * @uses bbp_get_view_query_args() To get the view query args 843 * @uses bbp_get_topic_post_type() To get the topic post type 844 * @uses bbp_get_reply_post_type() To get the reply post type 845 * @uses is_multisite() To check if it's a multisite 846 * @uses remove_action() To remove the auto save post revision action 819 847 */ 820 848 function bbp_pre_get_posts( $wp_query ) { 821 849 global $bbp, $wp_version; … … 929 957 * @param string $seplocation Optional. Direction to display title, 'right'. 930 958 * @uses bbp_is_user_profile_page() To check if it's a user profile page 931 959 * @uses bbp_is_user_profile_edit() To check if it's a user profile edit page 960 * @uses bbp_is_user_home() To check if the profile page is of the current user 932 961 * @uses get_query_var() To get the user id 933 962 * @uses get_userdata() To get the user data 963 * @uses bbp_is_forum() To check if it's a forum 964 * @uses bbp_get_forum_title() To get the forum title 965 * @uses bbp_is_topic() To check if it's a topic 966 * @uses bbp_get_topic_title() To get the topic title 967 * @uses bbp_is_reply() To check if it's a reply 968 * @uses bbp_get_reply_title() To get the reply title 969 * @uses is_tax() To check if it's the tag page 970 * @uses get_queried_object() To get the queried object 971 * @uses bbp_is_view() To check if it's a view 972 * @uses bbp_get_view_title() To get the view title 934 973 * @uses apply_filters() Calls 'bbp_raw_title' with the title 935 974 * @uses apply_filters() Calls 'bbp_profile_page_wp_title' with the title, 936 975 * separator and separator location … … 1138 1177 if ( empty( $redirect_to ) ) 1139 1178 $redirect_to = home_url( isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : '' ); 1140 1179 1141 $ url = add_query_arg( array( 'redirect_to' => esc_url( $redirect_to ) ), $url);1180 $redirect_to = esc_url( add_query_arg( array( 'loggedout' => '1' ), $redirect_to ) ); 1142 1181 1182 $url = add_query_arg( array( 'redirect_to' => $redirect_to ), $url ); 1183 1143 1184 return apply_filters( 'bbp_logout_url', $url, $redirect_to ); 1144 1185 } 1145 1186 … … 1148 1189 /** 1149 1190 * Query the DB and get the last public post_id that has parent_id as post_parent 1150 1191 * 1151 * @global db $wpdb 1152 * @param int $parent_id 1153 * @param string $post_type 1192 * @param int $parent_id Parent id 1193 * @param string $post_type Post type. Defaults to 'post' 1194 * @uses bbp_get_topic_post_type() To get the topic post type 1195 * @uses wp_cache_get() To check if there is a cache of the last child id 1196 * @uses wpdb::prepare() To prepare the query 1197 * @uses wpdb::get_var() To get the result of the query in a variable 1198 * @uses wp_cache_set() To set the cache for future use 1199 * @uses apply_filters() Calls 'bbp_get_public_child_last_id' with the child 1200 * id, parent id and post type 1154 1201 * @return int The last active post_id 1155 1202 */ 1156 1203 function bbp_get_public_child_last_id( $parent_id = 0, $post_type = 'post' ) { … … 1160 1207 return false; 1161 1208 1162 1209 // The ID of the cached query 1163 $cache_id = 'bbp_parent_' . $parent_id . '_type_' . $post_type . '_child_last_id'; 1210 $cache_id = 'bbp_parent_' . $parent_id . '_type_' . $post_type . '_child_last_id'; 1211 $post_status = array( 'publish' ); 1164 1212 1213 if ( $post_type == bbp_get_topic_post_type() ) 1214 $post_status[] = $bbp->closed_status_id; 1215 1216 $post_status = "'" . join( "', '", $post_status ) . "'"; 1217 1165 1218 if ( !$child_id = wp_cache_get( $cache_id, 'bbpress' ) ) { 1166 $child_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_status = 'publish'AND post_type = '%s' ORDER BY ID DESC LIMIT 1;", $parent_id, $post_type ) );1219 $child_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s' ORDER BY ID DESC LIMIT 1;", $parent_id, $post_type ) ); 1167 1220 wp_cache_set( $cache_id, $child_id, 'bbpress' ); 1168 1221 } 1169 1222 … … 1173 1226 /** 1174 1227 * Query the DB and get a count of public children 1175 1228 * 1176 * @global db $wpdb 1177 * @param int $parent_id 1178 * @param string $post_type 1229 * @param int $parent_id Parent id 1230 * @param string $post_type Post type. Defaults to 'post' 1231 * @uses bbp_get_topic_post_type() To get the topic post type 1232 * @uses wp_cache_get() To check if there is a cache of the children count 1233 * @uses wpdb::prepare() To prepare the query 1234 * @uses wpdb::get_var() To get the result of the query in a variable 1235 * @uses wp_cache_set() To set the cache for future use 1236 * @uses apply_filters() Calls 'bbp_get_public_child_count' with the child 1237 * count, parent id and post type 1179 1238 * @return int The number of children 1180 1239 */ 1181 1240 function bbp_get_public_child_count( $parent_id = 0, $post_type = 'post' ) { … … 1185 1244 return false; 1186 1245 1187 1246 // The ID of the cached query 1188 $cache_id = 'bbp_parent_' . $parent_id . '_type_' . $post_type . '_child_count'; 1247 $cache_id = 'bbp_parent_' . $parent_id . '_type_' . $post_type . '_child_count'; 1248 $post_status = array( 'publish' ); 1189 1249 1250 if ( $post_type == bbp_get_topic_post_type() ) 1251 $post_status[] = $bbp->closed_status_id; 1252 1253 $post_status = "'" . join( "', '", $post_status ) . "'"; 1254 1190 1255 if ( !$child_count = wp_cache_get( $cache_id, 'bbpress' ) ) { 1191 $child_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( '" . join( "', '", array( 'publish', $bbp->closed_status_id ) ) . "') AND post_type = '%s';", $parent_id, $post_type ) );1256 $child_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s';", $parent_id, $post_type ) ); 1192 1257 wp_cache_set( $cache_id, $child_count, 'bbpress' ); 1193 1258 } 1194 1259 … … 1196 1261 } 1197 1262 1198 1263 /** 1199 * Query the DB and get a the child ID's of public children1264 * Query the DB and get a the child id's of public children 1200 1265 * 1201 * @global db $wpdb 1202 * @param int $parent_id 1203 * @param string $post_type 1204 * @return int The number of children 1266 * @param int $parent_id Parent id 1267 * @param string $post_type Post type. Defaults to 'post' 1268 * @uses bbp_get_topic_post_type() To get the topic post type 1269 * @uses wp_cache_get() To check if there is a cache of the children 1270 * @uses wpdb::prepare() To prepare the query 1271 * @uses wpdb::get_col() To get the result of the query in an array 1272 * @uses wp_cache_set() To set the cache for future use 1273 * @uses apply_filters() Calls 'bbp_get_public_child_ids' with the child ids, 1274 * parent id and post type 1275 * @return array The array of children 1205 1276 */ 1206 1277 function bbp_get_public_child_ids( $parent_id = 0, $post_type = 'post' ) { 1207 1278 global $wpdb, $bbp; … … 1210 1281 return false; 1211 1282 1212 1283 // The ID of the cached query 1213 $cache_id = 'bbp_parent_' . $parent_id . '_type_' . $post_type . '_child_ids'; 1284 $cache_id = 'bbp_parent_' . $parent_id . '_type_' . $post_type . '_child_ids'; 1285 $post_status = array( 'publish' ); 1214 1286 1287 if ( $post_type == bbp_get_topic_post_type() ) 1288 $post_status[] = $bbp->closed_status_id; 1289 1290 $post_status = "'" . join( "', '", $post_status ) . "'"; 1291 1215 1292 if ( !$child_ids = wp_cache_get( $cache_id, 'bbpress' ) ) { 1216 $child_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( '" . join( "', '", array( 'publish', $bbp->closed_status_id ) ) . "') AND post_type = '%s' ORDER BY ID DESC;", $parent_id, $post_type ) );1293 $child_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s' ORDER BY ID DESC;", $parent_id, $post_type ) ); 1217 1294 wp_cache_set( $cache_id, $child_ids, 'bbpress' ); 1218 1295 } 1219 1296 -
bbp-includes/bbp-general-template.php
38 38 * 39 39 * @since bbPress (r2549) 40 40 * 41 * @uses WP_Query42 *43 41 * @param int $post_id Possible post_id to check 44 * @return bool 42 * @uses bbp_get_forum_post_type() To get the forum post type 43 * @uses is_singular() To check if it's the single post page 44 * @uses get_post_field() To get the post type of the post id 45 * @uses WP_Query To make some checks 46 * @return bool True if it's a forum page, false if not 45 47 */ 46 48 function bbp_is_forum( $post_id = 0 ) { 47 49 global $wp_query, $bbp; … … 68 70 * 69 71 * @since bbPress (r2549) 70 72 * 71 * @uses WP_Query72 * @uses bbp_is_topic_edit() To check if it's a topic edit page73 *74 73 * @param int $post_id Possible post_id to check 75 * @return bool 74 * @uses bbp_is_topic_edit() To return false if it's a topic edit page 75 * @uses bbp_get_topic_post_type() To get the topic post type 76 * @uses is_singular() To check if it's the single post page 77 * @uses get_post_field() To get the post type of the post id 78 * @uses WP_Query To make some checks 79 * @return bool True if it's a topic page, false if not 76 80 */ 77 81 function bbp_is_topic( $post_id = 0 ) { 78 82 global $wp_query, $bbp; … … 104 108 * @since bbPress (r2753) 105 109 * 106 110 * @uses WP_Query Checks if WP_Query::bbp_is_topic_edit is true 107 * @return bool 111 * @return bool True if it's the topic edit page, false if not 108 112 */ 109 113 function bbp_is_topic_edit() { 110 114 global $wp_query; … … 121 125 * @since bbPress (r2756) 122 126 * 123 127 * @uses bbp_is_topic_edit() To check if it's a topic edit page 124 * @return bool 128 * @return bool True if it's the topic merge page, false if not 125 129 */ 126 130 function bbp_is_topic_merge() { 127 131 … … 137 141 * @since bbPress (r2756) 138 142 * 139 143 * @uses bbp_is_topic_edit() To check if it's a topic edit page 140 * @return bool 144 * @return bool True if it's the topic split page, false if not 141 145 */ 142 146 function bbp_is_topic_split() { 143 147 … … 147 151 return false; 148 152 } 149 153 154 150 155 /** 151 156 * Check if current page is a bbPress reply 152 157 * 153 158 * @since bbPress (r2549) 154 159 * 155 * @uses WP_Query156 * @uses bbp_is_reply_edit() To check if it's a reply edit page157 *158 160 * @param int $post_id Possible post_id to check 159 * @return bool 161 * @uses bbp_is_reply_edit() To return false if it's a reply edit page 162 * @uses bbp_get_reply_post_type() To get the reply post type 163 * @uses is_singular() To check if it's the single post page 164 * @uses get_post_field() To get the post type of the post id 165 * @uses WP_Query To make some checks 166 * @return bool True if it's a reply page, false if not 160 167 */ 161 168 function bbp_is_reply( $post_id = 0 ) { 162 169 global $wp_query, $bbp; … … 188 195 * @since bbPress (r2753) 189 196 * 190 197 * @uses WP_Query Checks if WP_Query::bbp_is_reply_edit is true 191 * @return bool 198 * @return bool True if it's the reply edit page, false if not 192 199 */ 193 200 function bbp_is_reply_edit() { 194 201 global $wp_query; … … 210 217 * to true. 211 218 * @uses bbp_is_user_profile_page() To check if it's the user profile page 212 219 * @uses bbp_get_query_name() To get the query name 213 * @return bool 220 * @return bool True if it's the favorites page, false if not 214 221 */ 215 222 function bbp_is_favorites( $query_name_check = true ) { 216 223 if ( !bbp_is_user_profile_page() ) … … 233 240 * to true. 234 241 * @uses bbp_is_user_profile_page() To check if it's the user profile page 235 242 * @uses bbp_get_query_name() To get the query name 236 * @return bool 243 * @return bool True if it's the subscriptions page, false if not 237 244 */ 238 245 function bbp_is_subscriptions( $query_name_check = true ) { 239 246 if ( !bbp_is_user_profile_page() ) … … 257 264 * to true. 258 265 * @uses bbp_is_user_profile_page() To check if it's the user profile page 259 266 * @uses bbp_get_query_name() To get the query name 260 * @return bool 267 * @return bool True if it's the topics created page, false if not 261 268 */ 262 269 function bbp_is_topics_created( $query_name_check = true ) { 263 270 if ( !bbp_is_user_profile_page() ) … … 275 282 * @uses bbPres Checks if bbPress::displayed_user is set and if 276 283 * bbPress::displayed_user::ID equals bbPress::current_user::ID 277 284 * or not 278 * @return bool 285 * @return bool True if it's the user's home, false if not 279 286 */ 280 287 function bbp_is_user_home() { 281 288 global $bbp; … … 292 299 * @since bbPress (r2688) 293 300 * 294 301 * @uses WP_Query Checks if WP_Query::bbp_is_user_profile_page is set to true 295 * @return bool 302 * @return bool True if it's a user's profile page, false if not 296 303 */ 297 304 function bbp_is_user_profile_page() { 298 305 global $wp_query; … … 309 316 * @since bbPress (r2688) 310 317 * 311 318 * @uses WP_Query Checks if WP_Query::bbp_is_user_profile_edit is set to true 312 * @return bool 319 * @return bool True if it's a user's profile edit page, false if not 313 320 */ 314 321 function bbp_is_user_profile_edit() { 315 322 global $wp_query; … … 360 367 * @uses bbp_is_subscriptions() 361 368 * @uses bbp_is_favorites() 362 369 * @uses bbp_is_topics_created() 363 * 364 * @return array 370 * @return array Body Classes 365 371 */ 366 372 function bbp_body_class( $wp_classes, $custom_classes = false ) { 367 373 … … 477 483 if ( empty( $url ) && ( !$url = wp_get_referer() ) && ( !empty( $_SERVER['REQUEST_URI'] ) ) ) 478 484 $url = $_SERVER['REQUEST_URI']; 479 485 480 $url = (string) esc_attr( $url ); 486 // Remove loggedout query arg if it's there 487 $url = (string) esc_attr( remove_query_arg( 'loggedout', $url ) ); 481 488 482 489 $referer_field = '<input type="hidden" name="redirect_to" value="' . $url . '" />'; 483 490 … … 630 637 * dropdown 631 638 * @uses current_user_can() To check if the current user can read 632 639 * private forums 640 * @uses bbp_get_forum_post_type() To get the forum post type 641 * @uses bbp_get_topic_post_type() To get the topic post type 633 642 * @uses walk_page_dropdown_tree() To generate the dropdown using the 634 643 * walker 635 644 * @uses apply_filters() Calls 'bbp_get_dropdown' with the dropdown … … 1008 1017 * 1009 1018 * @since bbPress (r2692) 1010 1019 * 1011 * @uses bbp_set_query_name() To set the query var '_bbp_query_name' to ''1020 * @uses bbp_set_query_name() To set the query var '_bbp_query_name' value to '' 1012 1021 */ 1013 1022 function bbp_reset_query_name() { 1014 1023 bbp_set_query_name(); … … 1050 1059 * @uses bbp_get_topic_permalink() To get the topic link 1051 1060 * @uses bbp_get_reply_permalink() To get the reply link 1052 1061 * @uses get_permalink() To get the permalink 1062 * @uses bbp_get_forum_post_type() To get the forum post type 1063 * @uses bbp_get_topic_post_type() To get the topic post type 1064 * @uses bbp_get_reply_post_type() To get the reply post type 1053 1065 * @uses bbp_get_forum_title() To get the forum title 1054 1066 * @uses bbp_get_topic_title() To get the topic title 1055 1067 * @uses bbp_get_reply_title() To get the reply title … … 1141 1153 return apply_filters( 'bbp_get_allowed_tags', allowed_tags() ); 1142 1154 } 1143 1155 1144 /** Errors ********************************************************************/1156 /** Errors & Messages *********************************************************/ 1145 1157 1146 1158 /** 1147 * Display possible error messages inside a template file1159 * Display possible errors & messages inside a template file 1148 1160 * 1149 1161 * @since bbPress (r2688) 1150 1162 * … … 1153 1165 * messages 1154 1166 * @uses is_wp_error() To check if it's a {@link WP_Error} 1155 1167 */ 1156 function bbp_ error_messages() {1168 function bbp_template_notices() { 1157 1169 global $bbp; 1158 1170 1159 if ( isset( $bbp->errors ) && is_wp_error( $bbp->errors ) && $bbp->errors->get_error_codes() ) : ?> 1171 if ( !isset( $bbp->errors ) || !is_wp_error( $bbp->errors ) || !$bbp->errors->get_error_codes() ) 1172 return; 1160 1173 1174 $errors = $messages = array(); 1175 1176 foreach ( $bbp->errors->get_error_codes() as $code ) { 1177 $severity = $bbp->errors->get_error_data( $code ); 1178 foreach ( $bbp->errors->get_error_messages( $code ) as $error ) { 1179 if ( 'message' == $severity ) 1180 $messages[] = $error; 1181 else 1182 $errors[] = $error; 1183 } 1184 } 1185 1186 if ( !empty( $errors ) ) : ?> 1187 1161 1188 <div class="bbp-template-notice error"> 1162 1189 <p> 1163 <?php echo implode( "</p>\n<p>", $ bbp->errors->get_error_messages()); ?>1190 <?php echo implode( "</p>\n<p>", $errors ); ?> 1164 1191 </p> 1165 1192 </div> 1166 1193 1167 <?php endif; 1194 <?php endif; 1195 1196 if ( !empty( $messages ) ) : ?> 1197 1198 <div class="bbp-template-notice"> 1199 <p> 1200 <?php echo implode( "</p>\n<p>", $messages ); ?> 1201 </p> 1202 </div> 1203 1204 <?php endif; 1168 1205 } 1169 1206 1170 1207 /** Login/logout/register/lost pass *******************************************/ … … 1192 1229 * @return string The logout link 1193 1230 */ 1194 1231 function bbp_get_logout_link( $redirect_to = '' ) { 1195 return apply_filters( 'bbp_get_logout_link', '<a href="' . wp_logout_url() . '" class="button logout-link">' . __( 'Log Out', 'bbpress' ) . '</a>', $redirect_to ); 1232 if ( empty( $redirect_to ) ) 1233 $redirect_to = add_query_arg( array( 'loggedout' => '1' ) ); 1234 1235 return apply_filters( 'bbp_get_logout_link', '<a href="' . wp_logout_url( $redirect_to ) . '" class="button logout-link">' . __( 'Log Out', 'bbpress' ) . '</a>', $redirect_to ); 1196 1236 } 1197 1237 1198 1238 ?> -
bbp-includes/bbp-hooks.php
75 75 add_action( 'widgets_init', create_function( '', 'return register_widget("BBP_Topics_Widget");' ) ); 76 76 add_action( 'widgets_init', create_function( '', 'return register_widget("BBP_Replies_Widget");' ) ); 77 77 78 // Template - Head, foot, errors and notices 79 add_action( 'wp_head', 'bbp_head' ); 80 add_filter( 'wp_title', 'bbp_title', 10, 3 ); 81 add_action( 'wp_footer', 'bbp_footer' ); 82 add_action( 'bbp_template_notices', 'bbp_error_messages' ); 83 add_action( 'bbp_template_notices', 'bbp_topic_notices' ); 78 // Template - Head, foot, errors and messages 79 add_action( 'wp_head', 'bbp_head' ); 80 add_filter( 'wp_title', 'bbp_title', 10, 3 ); 81 add_action( 'wp_footer', 'bbp_footer' ); 82 add_action( 'bbp_loaded', 'bbp_login_notices' ); 83 add_action( 'bbp_head', 'bbp_topic_notices' ); 84 add_action( 'bbp_template_notices', 'bbp_template_notices' ); 84 85 85 86 // Add to body class 86 87 add_filter( 'body_class', 'bbp_body_class', 10, 2 ); … … 299 300 bbp_pre_anonymous_filters(); 300 301 301 302 /** 302 * On multiblog installations you must first allow themes to be activated and show303 * up on the theme selection screen. This function will let the bbPress bundled304 * themes show up and bypass this step.303 * On multiblog installations you must first allow themes to be activated and 304 * show up on the theme selection screen. This function will let the bbPress 305 * bundled themes show up and bypass this step. 305 306 * 306 307 * @since bbPress (r2944) 307 308 * 308 * @uses is_super_admin() 309 * @uses apply_filters() 309 * @uses is_super_admin() To check if the user is site admin 310 * @uses apply_filters() Calls 'bbp_allowed_themes' with the allowed themes list 310 311 */ 311 312 function bbp_allowed_themes( $themes ) { 312 313 if ( !is_super_admin() ) -
bbp-includes/bbp-topic-template.php
10 10 /** Post Type *****************************************************************/ 11 11 12 12 /** 13 * Return the unique IDof the custom post type for topics13 * Output the unique id of the custom post type for topics 14 14 * 15 15 * @since bbPress (r2857) 16 16 * 17 * @global bbPress $bbp 18 * @return string 17 * @uses bbp_get_topic_post_type() To get the topic post type 19 18 */ 20 19 function bbp_topic_post_type() { 21 20 echo bbp_get_topic_post_type(); 22 21 } 23 22 /** 24 * Return the unique IDof the custom post type for topics23 * Return the unique id of the custom post type for topics 25 24 * 26 25 * @since bbPress (r2857) 27 26 * 28 * @global bbPress $bbp 29 * @return string 27 * @uses apply_filters() Calls 'bbp_get_topic_post_type' with the topic 28 * post type id 29 * @return string The unique topic post type id 30 30 */ 31 31 function bbp_get_topic_post_type() { 32 32 global $bbp; 33 33 34 return apply_filters( 'bbp_get_topic_post_type', $bbp->topic_post_type ); 34 35 } 35 36 … … 41 42 * @since bbPress (r2485) 42 43 * 43 44 * @param mixed $args All the arguments supported by {@link WP_Query} 44 * @uses bbp_is_user_profile_page() To check if it's the profile page45 * @uses get_the_ID() To get the id45 * @uses current_user_can() To check if the current user can edit other's topics 46 * @uses bbp_get_topic_post_type() To get the topic post type 46 47 * @uses WP_Query To make query and get the topics 47 48 * @uses is_page() To check if it's a page 48 49 * @uses bbp_is_forum() To check if it's a forum 50 * @uses bbp_get_forum_id() To get the forum id 49 51 * @uses bbp_get_paged() To get the current page value 50 52 * @uses bbp_get_super_stickies() To get the super stickies 51 53 * @uses bbp_get_stickies() To get the forum stickies … … 283 285 * @uses bbp_is_reply() To check if it it's a reply page 284 286 * @uses bbp_is_reply_edit() To check if it's a reply edit page 285 287 * @uses bbp_get_reply_topic_edit() To get the reply topic id 288 * @uses get_post_field() To get the post's post type 286 289 * @uses WP_Query::post::ID To get the topic id 287 * @uses apply_filters() Calls 'bbp_get_topic_id' with the topic id 290 * @uses apply_filters() Calls 'bbp_get_topic_id' with the topic id and 291 * supplied topic id 292 * @return int The topic id 288 293 */ 289 294 function bbp_get_topic_id( $topic_id = 0 ) { 290 295 global $bbp, $wp_query, $bbp; … … 529 534 * @uses bbp_get_topic_revisions() To get the topic revisions 530 535 * @uses bbp_get_topic_raw_revision_log() To get the raw revision log 531 536 * @uses bbp_get_topic_author_display_name() To get the topic author 532 * @uses bbp_get_ topic_author_link() To get the topic author link537 * @uses bbp_get_author_link() To get the topic author link 533 538 * @uses bbp_convert_date() To convert the date 534 539 * @uses bbp_get_time_since() To get the time in since format 535 540 * @uses apply_filters() Calls 'bbp_get_topic_revision_log' with the … … 758 763 * @param int $topic_id Optional. Topic id 759 764 * @uses bbp_get_topic_id() To get the topic id 760 765 * @uses bbp_get_topic_status() To get the topic status 761 * @return bool True if spam, false if not.766 * @return bool True if trashed, false if not. 762 767 */ 763 768 function bbp_is_topic_trash( $topic_id = 0 ) { 764 769 global $bbp; … … 814 819 * @uses bbp_get_topic_id() To get the topic id 815 820 * @uses bbp_is_topic_anonymous() To check if the topic is by an 816 821 * anonymous user 822 * @uses bbp_get_topic_author_id() To get the topic author id 823 * @uses get_the_author_meta() To get the display name of the author 824 * @uses get_post_meta() To get the name of the anonymous poster 817 825 * @uses apply_filters() Calls 'bbp_get_topic_author' with the author 818 826 * and topic id 819 827 * @return string Author of topic … … 1116 1124 * 1117 1125 * @param int $topic_id Optional. Topic id 1118 1126 * @uses bbp_get_topic_id() To get topic id 1119 * @uses get_post_field() To get get topic's parent 1127 * @uses get_post_meta() To retrieve get topic's forum id meta 1128 * @uses get_post_field() To get the topic's parent, i.e. forum id 1129 * @uses bbp_update_topic_forum_id() To update the topic forum id 1120 1130 * @uses apply_filters() Calls 'bbp_get_topic_forum_id' with the forum 1121 * id and topic id1131 * id and topic id 1122 1132 * @return int Topic forum id 1123 1133 */ 1124 1134 function bbp_get_topic_forum_id( $topic_id = 0 ) { … … 1139 1149 * 1140 1150 * @since bbPress (r2860) 1141 1151 * 1152 * @param int $topic_id Optional. Forum id 1142 1153 * @uses bbp_get_topic_last_active_id() To get the topic's last active id 1143 * @param int $topic_id Optional. Forum id1144 1154 */ 1145 1155 function bbp_topic_last_active_id( $topic_id = 0 ) { 1146 1156 echo bbp_get_topic_last_active_id( $topic_id ); … … 1483 1493 * @uses get_post_meta() To get the topic post count meta 1484 1494 * @uses apply_filters() Calls 'bbp_get_topic_post_count' with the 1485 1495 * post count and topic id 1486 * @return int post count1496 * @return int Post count 1487 1497 */ 1488 1498 function bbp_get_topic_post_count( $topic_id = 0 ) { 1489 1499 $topic_id = bbp_get_topic_id( $topic_id ); … … 1846 1856 * @uses bbp_get_topic() To get the topic 1847 1857 * @uses current_user_can() To check if the current user can delete the 1848 1858 * topic 1859 * @uses bbp_is_topic_trash() To check if the topic is trashed 1849 1860 * @uses bbp_get_topic_status() To get the topic status 1850 1861 * @uses add_query_arg() To add custom args to the url 1851 1862 * @uses wp_nonce_url() To nonce the url … … 2219 2230 * 2220 2231 * @uses bbp_is_topic() To check if it's a topic page 2221 2232 * @uses bbp_get_topic_status() To get the topic status 2233 * @uses bbp_get_topic_id() To get the topic id 2234 * @uses apply_filters() Calls 'bbp_topic_notices' with the notice text, topic 2235 * status and topic id 2236 * @uses bbPress::errors::add() To add the notices to the error handler 2222 2237 */ 2223 2238 function bbp_topic_notices() { 2224 2239 global $bbp; … … 2250 2265 } 2251 2266 2252 2267 // Filter notice text and bail if empty 2253 if ( ! 2254 return; ?>2268 if ( !$notice_text = apply_filters( 'bbp_topic_notices', $notice_text, $topic_status, bbp_get_topic_id() ) ) 2269 return; 2255 2270 2256 <div class="bbp-template-notice error"> 2257 <p><?php echo $notice_text; ?></p> 2258 </div> 2259 2260 <?php 2271 $bbp->errors->add( 'topic_notice', $notice_text, 'message' ); 2261 2272 } 2262 2273 2263 2274 /** … … 2335 2346 * 2336 2347 * @since bbPress (r2860) 2337 2348 * 2349 * @param array $args See {@link bbp_get_single_topic_description()} 2338 2350 * @uses bbp_get_single_topic_description() Return the eventual output 2339 *2340 * @param arr $args Arguments passed to alter output2341 2351 */ 2342 2352 function bbp_single_topic_description( $args = '' ) { 2343 2353 echo bbp_get_single_topic_description( $args ); … … 2348 2358 * 2349 2359 * @since bbPress (r2860) 2350 2360 * 2351 * @ uses wp_parse_args()2352 * @uses bbp_get_topic_id()2353 * @uses bbp_get_topic_topic_count()2354 * @uses bbp_get_topic_reply_count()2355 * @uses bbp_get_topic_subtopic_count()2356 * @uses bbp_get_topic_ freshness_link()2357 * @uses bbp_get_topic_ last_reply_id()2358 * @uses bbp_get_ reply_author_avatar()2359 * @uses bbp_get_ reply_author_link()2360 * @uses apply_filters()2361 * 2362 * @ param arr $args Arguments passed to alter output2363 * 2361 * @param mixed $args This function supports these arguments: 2362 * - topic_id: Topic id 2363 * - before: Before the text 2364 * - after: After the text 2365 * - size: Size of the avatar 2366 * @uses bbp_get_topic_id() To get the topic id 2367 * @uses bbp_get_topic_voice_count() To get the topic voice count 2368 * @uses bbp_get_topic_reply_count() To get the topic reply count 2369 * @uses bbp_get_topic_freshness_link() To get the topic freshness link 2370 * @uses bbp_get_topic_last_active_id() To get the topic last active id 2371 * @uses bbp_get_reply_author_link() To get the reply author link 2372 * @uses apply_filters() Calls 'bbp_get_single_topic_description' with 2373 * the description and args 2364 2374 * @return string Filtered topic description 2365 2375 */ 2366 2376 function bbp_get_single_topic_description( $args = '' ) { -
bbp-includes/bbp-user-template.php
537 537 * 538 538 * @param int $user_id Optional. User id 539 539 * @uses bbp_get_user_profile_url() To get the user profile url 540 * @uses apply_filters() Calls 'bbp_get_ favorites_permalink' with the541 * user profile url and user id540 * @uses apply_filters() Calls 'bbp_get_subscriptions_permalink' with 541 * the user profile url and user id 542 542 * @return string Permanent link to user subscriptions page 543 543 */ 544 544 function bbp_get_subscriptions_permalink( $user_id = 0 ) { … … 763 763 764 764 /** Login *********************************************************************/ 765 765 766 function bbp_login_notices() { 767 global $bbp; 768 769 if ( !empty( $_GET['loggedout'] ) && true == $_GET['loggedout'] ) { 770 $bbp->errors->add( 'loggedout', __( 'You are now logged out.', 'bbpress' ), 'message' ); 771 } elseif ( !empty( $_GET['registration'] ) && 'disabled' == $_GET['registration'] ) { 772 $bbp->errors->add( 'registerdisabled', __( 'User registration is currently not allowed.', 'bbpress' ) ); 773 } elseif ( !empty( $_GET['checkemail'] ) && in_array( $_GET['checkemail'], array( 'confirm', 'newpass', 'registered' ) ) ) { 774 switch ( $_GET['checkemail'] ) { 775 case 'confirm' : 776 $bbp->errors->add( 'confirm', __( 'Check your e-mail for the confirmation link.', 'bbpress' ), 'message' ); 777 break; 778 case 'newpass' : 779 $bbp->errors->add( 'newpass', __( 'Check your e-mail for your new password.', 'bbpress' ), 'message' ); 780 break; 781 case 'registered' : 782 $bbp->errors->add( 'registered', __( 'Registration complete. Please check your e-mail.', 'bbpress' ), 'message' ); 783 break; 784 } 785 } 786 } 787 766 788 /** 767 789 * Redirect a user back to their profile if they are already logged in. 768 790 * … … 812 834 * 813 835 * @since bbPress (r2815) 814 836 * 837 * @uses bbp_login_url() To get the login url 838 * @uses bbp_redirect_to_field() To output the redirect to field 815 839 * @uses wp_nonce_field() To generate hidden nonce fields 816 840 */ 817 841 function bbp_user_register_fields() { 818 842 ?> 819 843 820 <input type="hidden" name="action" value=" bbp-user-register" id="bbp_user_register" />844 <input type="hidden" name="action" value="register" /> 821 845 <input type="hidden" name="user-cookie" value="1" /> 822 846 847 <?php bbp_redirect_to_field( add_query_arg( array( 'checkemail' => 'registered' ), bbp_login_url() ) ); ?> 848 823 849 <?php wp_nonce_field( 'bbp-user-register' ); 824 850 } 825 851 … … 861 887 * @since bbPress (r2875) 862 888 * 863 889 * @param mixed $args Optional. If an integer, it is used as reply id. 864 * @uses bbp_get_reply_id() To get the reply id865 890 * @uses bbp_is_topic() To check if it's a topic page 891 * @uses bbp_get_topic_author_link() To get the topic author link 866 892 * @uses bbp_is_reply() To check if it's a reply page 893 * @uses bbp_get_reply_author_link() To get the reply author link 894 * @uses get_post_field() To get the post author 867 895 * @uses bbp_is_reply_anonymous() To check if the reply is by an 868 896 * anonymous user 869 * @uses bbp_get_reply_author() To get the replyauthor name870 * @uses bbp_get_ reply_author_url() To get the reply authorurl871 * @uses bbp_get_reply_author_avatar() To get the replyauthor avatar897 * @uses get_the_author_meta() To get the author name 898 * @uses bbp_get_user_profile_url() To get the author profile url 899 * @uses get_avatar() To get the author avatar 872 900 * @uses apply_filters() Calls 'bbp_get_reply_author_link' with the 873 901 * author link and args 874 902 * @return string Author link of reply -
bbp-includes/bbp-widgets.php
65 65 <fieldset> 66 66 <legend><?php _e( 'Login', 'bbpress' ); ?></legend> 67 67 68 <?php do_action( 'bbp_template_notices' ); ?>69 70 68 <div class="bbp-username"> 71 69 <label for="user_login"><?php _e( 'Username', 'bbpress' ); ?>: </label> 72 70 <input type="text" name="log" value="<?php bbp_sanitize_val( 'user_login', 'text' ); ?>" size="20" id="user_login" tabindex="<?php bbp_tab_index(); ?>" /> … … 182 180 * @param mixed $args Arguments 183 181 * @param array $instance Instance 184 182 * @uses apply_filters() Calls 'bbp_forum_widget_title' with the title 183 * @uses get_option() To get the forums per page option 184 * @uses current_user_can() To check if the current user can read 185 * private() To resety name 186 * @uses bbp_set_query_name() To set the query name to 'bbp_widget' 187 * @uses bbp_reset_query_name() To reset the query name 185 188 * @uses bbp_has_forums() The main forum loop 186 189 * @uses bbp_forums() To check whether there are more forums available 187 190 * in the loop … … 314 317 * @param mixed $args 315 318 * @param array $instance 316 319 * @uses apply_filters() Calls 'bbp_topic_widget_title' with the title 320 * @uses bbp_set_query_name() To set the query name to 'bbp_widget' 321 * @uses bbp_reset_query_name() To reset the query name 317 322 * @uses bbp_has_topics() The main topic loop 318 323 * @uses bbp_topics() To check whether there are more topics available 319 324 * in the loop 320 325 * @uses bbp_the_topic() Loads up the current topic in the loop 321 326 * @uses bbp_topic_permalink() To display the topic permalink 322 327 * @uses bbp_topic_title() To display the topic title 323 * @uses bbp_get_topic_last_active_time() To get the topic last active time 328 * @uses bbp_get_topic_last_active_time() To get the topic last active 329 * time 324 330 * @uses bbp_get_topic_id() To get the topic id 325 331 * @uses bbp_get_topic_reply_count() To get the topic reply count 326 332 */ -
bbp-themes/bbp-twentyten/bbpress/form-user-login.php
13 13 <fieldset> 14 14 <legend><?php _e( 'Login', 'bbpress' ); ?></legend> 15 15 16 <?php do_action( 'bbp_template_notices' ); ?>17 18 16 <div class="bbp-username"> 19 17 <label for="user_login"><?php _e( 'Username', 'bbpress' ); ?>: </label> 20 18 <input type="text" name="log" value="<?php bbp_sanitize_val( 'user_login', 'text' ); ?>" size="20" id="user_login" tabindex="<?php bbp_tab_index(); ?>" /> -
bbp-themes/bbp-twentyten/bbpress/form-user-register.php
9 9 10 10 ?> 11 11 12 <form method="post" action="<?php bbp_wp_login_action( array( ' action' => 'register', 'context' => 'login_post' ) ); ?>" class="bbp-login-form">12 <form method="post" action="<?php bbp_wp_login_action( array( 'context' => 'login_post' ) ); ?>" class="bbp-login-form"> 13 13 <fieldset> 14 14 <legend><?php _e( 'Register', 'bbpress' ); ?></legend> 15 15 16 <?php do_action( 'bbp_template_notices' ); ?>17 18 16 <div class="bbp-username"> 19 17 <label for="user_login"><?php _e( 'Username', 'bbpress' ); ?>: </label> 20 18 <input type="text" name="user_login" value="<?php bbp_sanitize_val( 'user_login' ); ?>" size="20" id="user_login" tabindex="<?php bbp_tab_index(); ?>" /> … … 25 23 <input type="text" name="user_email" value="<?php bbp_sanitize_val( 'user_email' ); ?>" size="20" id="user_email" tabindex="<?php bbp_tab_index(); ?>" /> 26 24 </div> 27 25 26 <?php do_action( 'register_form' ); ?> 27 28 <p id="reg_passmail"><?php _e( 'A password will be e-mailed to you.', 'bbpress' ) ?></p> 29 28 30 <div class="bbp-submit-wrapper"> 29 31 30 <?php do_action( 'register_form' ); ?>31 32 32 <button type="submit" name="user-submit" tabindex="<?php bbp_tab_index(); ?>" class="user-submit"><?php _e( 'Register', 'bbpress' ); ?></button> 33 33 34 34 <?php bbp_user_register_fields(); ?>