Changeset 2787
- Timestamp:
- 01/09/2011 08:43:56 PM (14 years ago)
- Location:
- branches/plugin
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-admin/bbp-admin.php
r2786 r2787 211 211 212 212 // Add the per page section 213 add_settings_section( 'bbp_slugs', __( ' Slugs','bbpress' ), 'bbp_admin_setting_callback_slugs_section', 'bbpress' );213 add_settings_section( 'bbp_slugs', __( 'Forums', 'bbpress' ), 'bbp_admin_setting_callback_slugs_section', 'bbpress' ); 214 214 215 215 // Root slug setting 216 add_settings_field( '_bbp_root_slug', __( ' Root Slug','bbpress' ), 'bbp_admin_setting_callback_root_slug', 'bbpress', 'bbp_slugs' );216 add_settings_field( '_bbp_root_slug', __( 'Forum base', 'bbpress' ), 'bbp_admin_setting_callback_root_slug', 'bbpress', 'bbp_slugs' ); 217 217 register_setting ( 'bbpress', '_bbp_root_slug', 'sanitize_title' ); 218 218 219 219 // Include root setting 220 add_settings_field( '_bbp_include_root', __( ' Prefix Root?','bbpress' ), 'bbp_admin_setting_callback_include_root', 'bbpress', 'bbp_slugs' );220 add_settings_field( '_bbp_include_root', __( 'Include base?', 'bbpress' ), 'bbp_admin_setting_callback_include_root', 'bbpress', 'bbp_slugs' ); 221 221 register_setting ( 'bbpress', '_bbp_include_root', 'intval' ); 222 222 223 223 // User slug setting 224 add_settings_field( '_bbp_user_slug', __( 'User Slug', 'bbpress' ), 'bbp_admin_setting_callback_user_slug', 'bbpress', 'bbp_slugs' );224 add_settings_field( '_bbp_user_slug', __( 'User base', 'bbpress' ), 'bbp_admin_setting_callback_user_slug', 'bbpress', 'bbp_slugs' ); 225 225 register_setting ( 'bbpress', '_bbp_user_slug', 'sanitize_title' ); 226 226 227 227 // Forum slug setting 228 add_settings_field( '_bbp_forum_slug', __( 'Forum Slug', 'bbpress' ), 'bbp_admin_setting_callback_forum_slug', 'bbpress', 'bbp_slugs' );228 add_settings_field( '_bbp_forum_slug', __( 'Forum slug', 'bbpress' ), 'bbp_admin_setting_callback_forum_slug', 'bbpress', 'bbp_slugs' ); 229 229 register_setting ( 'bbpress', '_bbp_forum_slug', 'sanitize_title' ); 230 230 231 231 // Topic slug setting 232 add_settings_field( '_bbp_topic_slug', __( 'Topic Slug', 'bbpress' ), 'bbp_admin_setting_callback_topic_slug', 'bbpress', 'bbp_slugs' );232 add_settings_field( '_bbp_topic_slug', __( 'Topic slug', 'bbpress' ), 'bbp_admin_setting_callback_topic_slug', 'bbpress', 'bbp_slugs' ); 233 233 register_setting ( 'bbpress', '_bbp_topic_slug', 'sanitize_title' ); 234 234 235 235 // Reply slug setting 236 add_settings_field( '_bbp_reply_slug', __( 'Reply Slug', 'bbpress' ), 'bbp_admin_setting_callback_reply_slug', 'bbpress', 'bbp_slugs' );236 add_settings_field( '_bbp_reply_slug', __( 'Reply slug', 'bbpress' ), 'bbp_admin_setting_callback_reply_slug', 'bbpress', 'bbp_slugs' ); 237 237 register_setting ( 'bbpress', '_bbp_reply_slug', 'sanitize_title' ); 238 238 239 239 // Topic tag slug setting 240 add_settings_field( '_bbp_topic_tag_slug', __( 'Topic Tag Slug', 'bbpress' ), 'bbp_admin_setting_callback_topic_tag_slug', 'bbpress', 'bbp_slugs' );241 register_setting ( 'bbpress', '_bbp_topic_tag_slug', 240 add_settings_field( '_bbp_topic_tag_slug', __( 'Topic tag slug', 'bbpress' ), 'bbp_admin_setting_callback_topic_tag_slug', 'bbpress', 'bbp_slugs' ); 241 register_setting ( 'bbpress', '_bbp_topic_tag_slug', 'sanitize_title' ); 242 242 243 243 do_action( 'bbp_register_admin_settings' ); … … 345 345 * @uses current_user_can() To check if the current user is capable of 346 346 * editing the forum 347 * @uses get_post_field() To get the post type of the supplied id and 348 * check if it's a forum 347 * @uses bbp_get_forum() To get the forum 349 348 * @uses bbp_is_forum_closed() To check if the forum is closed 350 349 * @uses bbp_is_forum_category() To check if the forum is a category … … 365 364 return $forum_id; 366 365 367 if ( $bbp->forum_id != get_post_field( 'post_type',$forum_id ) )366 if ( !$forum = bbp_get_forum( $forum_id ) ) 368 367 return $forum_id; 369 368 … … 850 849 * @since bbPress (r2727) 851 850 * 852 * @uses get_post() To get the topic851 * @uses bbp_get_topic() To get the topic 853 852 * @uses current_user_can() To check if the user is capable of editing 854 853 * the topic … … 881 880 $post_data = array( 'ID' => $topic_id ); // Prelim array 882 881 883 if ( !$topic = get_post( $topic_id ) ) // Which topic?882 if ( !$topic = bbp_get_topic( $topic_id ) ) // Which topic? 884 883 wp_die( __( 'The topic was not found!', 'bbpress' ) ); 885 884 … … 944 943 * @since bbPress (r2727) 945 944 * 945 * @uses bbp_get_topic() To get the topic 946 946 * @uses bbp_get_topic_title() To get the topic title of the topic 947 947 * @uses esc_html() To sanitize the topic title … … 959 959 960 960 // Empty? No topic? 961 if ( empty( $notice ) || empty( $topic_id ) || !$topic = get_post( $topic_id ) )961 if ( empty( $notice ) || empty( $topic_id ) || !$topic = bbp_get_topic( $topic_id ) ) 962 962 return; 963 963 … … 1199 1199 if ( current_user_can( 'delete_topic', $topic->ID ) ) { 1200 1200 if ( $bbp->trash_status_id == $topic->post_status ) { 1201 $post_type_object = get_post_type_object( $ topic->post_type);1201 $post_type_object = get_post_type_object( $bbp->topic_id ); 1202 1202 $actions['untrash'] = "<a title='" . esc_attr( __( 'Restore this item from the Trash', 'bbpress' ) ) . "' href='" . wp_nonce_url( add_query_arg( array( '_wp_http_referer' => add_query_arg( array( 'post_type' => $bbp->topic_id ), admin_url( 'edit.php' ) ) ), admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $topic->ID ) ) ), 'untrash-' . $topic->post_type . '_' . $topic->ID ) . "'>" . __( 'Restore', 'bbpress' ) . "</a>"; 1203 1203 } elseif ( EMPTY_TRASH_DAYS ) { … … 1223 1223 * @since bbPress (r2740) 1224 1224 * 1225 * @uses get_post() To get the reply1225 * @uses bbp_get_reply() To get the reply 1226 1226 * @uses current_user_can() To check if the user is capable of editing 1227 1227 * the reply … … 1247 1247 $post_data = array( 'ID' => $reply_id ); // Prelim array 1248 1248 1249 if ( !$reply = get_post( $reply_id ) ) // Which reply?1249 if ( !$reply = bbp_get_reply( $reply_id ) ) // Which reply? 1250 1250 wp_die( __( 'The reply was not found!', 'bbpress' ) ); 1251 1251 … … 1291 1291 * @since bbPress (r2740) 1292 1292 * 1293 * @uses bbp_get_reply() To get the reply 1293 1294 * @uses bbp_get_reply_title() To get the reply title of the reply 1294 1295 * @uses esc_html() To sanitize the reply title … … 1306 1307 1307 1308 // Empty? No reply? 1308 if ( empty( $notice ) || empty( $reply_id ) || !$reply = get_post( $reply_id ) )1309 if ( empty( $notice ) || empty( $reply_id ) || !$reply = bbp_get_reply( $reply_id ) ) 1309 1310 return; 1310 1311 … … 1508 1509 if ( current_user_can( 'delete_reply', $reply->ID ) ) { 1509 1510 if ( $bbp->trash_status_id == $reply->post_status ) { 1510 $post_type_object = get_post_type_object( $ reply->post_type);1511 $post_type_object = get_post_type_object( $bbp->reply_id ); 1511 1512 $actions['untrash'] = "<a title='" . esc_attr( __( 'Restore this item from the Trash', 'bbpress' ) ) . "' href='" . add_query_arg( array( '_wp_http_referer' => add_query_arg( array( 'post_type' => $bbp->reply_id ), admin_url( 'edit.php' ) ) ), wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $reply->ID ) ), 'untrash-' . $reply->post_type . '_' . $reply->ID ) ) . "'>" . __( 'Restore', 'bbpress' ) . "</a>"; 1512 1513 } elseif ( EMPTY_TRASH_DAYS ) { -
branches/plugin/bbp-admin/bbp-settings.php
r2786 r2787 119 119 120 120 /** 121 * Forums per page setting field122 *123 * @todo Implement124 *125 * @since bbPress (r2786)126 *127 * @uses form_option() To output the option value128 */129 function bbp_admin_setting_callback_forums_per_page() {130 ?>131 132 <input name="_bbp_forums_per_page" type="text" id="_bbp_forums_per_page" value="<?php form_option( '_bbp_forums_per_page' ); ?>" class="small-text" />133 <label for="_bbp_forums_per_page"><?php _e( 'per page', 'bbpress' ); ?></label>134 135 <?php136 }137 138 /**139 121 * Topics per page setting field 140 122 * … … 178 160 ?> 179 161 180 <p><?php _e( 'Change the forum\'s slugs in this section.', 'bbpress' ); ?></p> 181 <p><?php printf( __( '<strong>Note</strong>: If you change any of these, all previous links would stop working. You must also go to the <a href="%s">permalinks</a> page and press the "Save Changes" button in order to make the changes take effect.', 'bbpress' ), get_admin_url( null, 'options-permalink.php' ) ); ?></p> 162 <p><?php printf( __( 'If you like, you may enter custom structures for your forum, topic, reply, and tag URLs here. If you change any of these, all previous links will stop working. If you leave these empty the defaults will be used.', 'bbpress' ), get_admin_url( null, 'options-permalink.php' ) ); ?></p> 182 163 183 164 <?php … … 303 284 function bbp_admin_settings() { 304 285 ?> 286 305 287 <div class="wrap"> 306 288 -
branches/plugin/bbp-includes/bbp-classes.php
r2758 r2787 257 257 258 258 if ( !empty( $current_forum ) ) { 259 $_current_page = get_post( $current_forum );259 $_current_page = bbp_get_forum( $current_forum ); 260 260 261 261 if ( isset( $_current_page->ancestors ) && in_array( $forum->ID, (array) $_current_page->ancestors ) ) -
branches/plugin/bbp-includes/bbp-forum-template.php
r2758 r2787 34 34 'posts_per_page' => -1, 35 35 'orderby' => 'menu_order', 36 'order' => 'ASC' 36 'order' => 'ASC', 37 'posts_per_page' => get_option( '_bbp_forums_per_page', 15 ) 37 38 ); 38 39 … … 134 135 return apply_filters( 'bbp_get_forum_id', (int) $bbp_forum_id ); 135 136 } 137 138 /** 139 * Gets a forum 140 * 141 * @since bbPress (r2787) 142 * 143 * @param int|object $forum forum id or forum object 144 * @param string $output Optional. OBJECT, ARRAY_A, or ARRAY_N. Default = OBJECT 145 * @param string $filter Optional Sanitation filter. See {@link sanitize_post()} 146 * @uses get_post() To get the forum 147 * @return mixed Null if error or forum (in specified form) if success 148 */ 149 function bbp_get_forum( $forum, $output = OBJECT, $filter = 'raw' ) { 150 global $bbp; 151 152 if ( empty( $forum ) || is_numeric( $forum ) ) 153 $forum = bbp_get_forum_id( $forum ); 154 155 if ( !$forum = get_post( $forum, OBJECT, $filter ) ) 156 return $forum; 157 158 if ( $bbp->forum_id !== $forum->post_type ) 159 return null; 160 161 if ( $output == OBJECT ) { 162 return $forum; 163 164 } elseif ( $output == ARRAY_A ) { 165 $_forum = get_object_vars( $forum ); 166 return $_forum; 167 168 } elseif ( $output == ARRAY_N ) { 169 $_forum = array_values( get_object_vars( $forum ) ); 170 return $_forum; 171 172 } 173 174 return apply_filters( 'bbp_get_forum', $forum ); 175 } 136 176 137 177 /** … … 306 346 * @param int $forum_id Optional. Forum id 307 347 * @uses bbp_get_forum_id() To get the forum id 308 * @uses get_post() To get the forum348 * @uses bbp_get_forum() To get the forum 309 349 * @uses apply_filters() Calls 'bbp_get_forum_ancestors' with the ancestors 310 350 * and forum id … … 314 354 $forum_id = bbp_get_forum_id( $forum_id ); 315 355 316 if ( $forum = get_post( $forum_id ) ) {356 if ( $forum = bbp_get_forum( $forum_id ) ) { 317 357 $ancestors = array(); 318 358 while ( 0 !== $forum->post_parent ) { 319 359 $ancestors[] = $forum->post_parent; 320 $forum = get_post( $forum->post_parent );360 $forum = bbp_get_forum( $forum->post_parent ); 321 361 } 322 362 } -
branches/plugin/bbp-includes/bbp-functions.php
r2784 r2787 419 419 * 420 420 * @uses bbPress:errors::add() To log various error messages 421 * @uses get_post() To get the reply421 * @uses bbp_get_reply() To get the reply 422 422 * @uses check_admin_referer() To verify the nonce and check the referer 423 423 * @uses bbp_is_reply_anonymous() To check if the reply was by an anonymous user … … 450 450 if ( empty( $_POST['bbp_reply_id'] ) || !$reply_id = (int) $_POST['bbp_reply_id'] ) { 451 451 $bbp->errors->add( 'bbp_edit_reply_id', __( '<strong>ERROR</strong>: Reply ID not found!', 'bbpress' ) ); 452 } elseif ( !$reply = get_post( $reply_id ) ) {452 } elseif ( !$reply = bbp_get_reply( $reply_id ) ) { 453 453 $bbp->errors->add( 'bbp_edit_reply_not_found', __( '<strong>ERROR</strong>: The reply you want to edit was not found!', 'bbpress' ) ); 454 454 } else { … … 792 792 * 793 793 * @uses bbPress:errors::add() To log various error messages 794 * @uses get_post() To get the topic794 * @uses bbp_get_topic() To get the topic 795 795 * @uses check_admin_referer() To verify the nonce and check the referer 796 796 * @uses bbp_is_topic_anonymous() To check if topic is by an anonymous user … … 829 829 if ( !$topic_id = (int) $_POST['bbp_topic_id'] ) { 830 830 $bbp->errors->add( 'bbp_edit_topic_id', __( '<strong>ERROR</strong>: Topic ID not found!', 'bbpress' ) ); 831 } elseif ( !$topic = get_post( $topic_id ) ) {831 } elseif ( !$topic = bbp_get_topic( $topic_id ) ) { 832 832 $bbp->errors->add( 'bbp_edit_topic_not_found', __( '<strong>ERROR</strong>: The topic you want to edit was not found!', 'bbpress' ) ); 833 833 } else { … … 1199 1199 * 1200 1200 * @uses bbPress:errors::add() To log various error messages 1201 * @uses get_post() To get the topics1201 * @uses bbp_get_topic() To get the topics 1202 1202 * @uses check_admin_referer() To verify the nonce and check the referer 1203 1203 * @uses current_user_can() To check if the current user can edit the topics … … 1234 1234 check_admin_referer( 'bbp-merge-topic_' . $source_topic_id ); 1235 1235 1236 if ( !$source_topic = get_post( $source_topic_id ) )1236 if ( !$source_topic = bbp_get_topic( $source_topic_id ) ) 1237 1237 $bbp->errors->add( 'bbp_merge_topic_source_not_found', __( '<strong>ERROR</strong>: The topic you want to merge was not found!', 'bbpress' ) ); 1238 1238 … … 1243 1243 $bbp->errors->add( 'bbp_merge_topic_destination_id', __( '<strong>ERROR</strong>: Destination topic ID not found!', 'bbpress' ) ); 1244 1244 1245 if ( !$destination_topic = get_post( $destination_topic_id ) )1245 if ( !$destination_topic = bbp_get_topic( $destination_topic_id ) ) 1246 1246 $bbp->errors->add( 'bbp_merge_topic_destination_not_found', __( '<strong>ERROR</strong>: The topic you want to merge to was not found!', 'bbpress' ) ); 1247 1247 … … 1384 1384 * 1385 1385 * @uses bbPress:errors::add() To log various error messages 1386 * @uses get_post() To get the reply and topics 1386 * @uses bbp_get_reply() To get the reply 1387 * @uses bbp_get_topic() To get the topics 1387 1388 * @uses check_admin_referer() To verify the nonce and check the referer 1388 1389 * @uses current_user_can() To check if the current user can edit the topics … … 1414 1415 $bbp->errors->add( 'bbp_split_topic_reply_id', __( '<strong>ERROR</strong>: Reply ID to split the topic from not found!', 'bbpress' ) ); 1415 1416 1416 if ( !$from_reply = get_post( $from_reply_id ) )1417 if ( !$from_reply = bbp_get_reply( $from_reply_id ) ) 1417 1418 $bbp->errors->add( 'bbp_split_topic_r_not_found', __( '<strong>ERROR</strong>: The reply you want to split from was not found!', 'bbpress' ) ); 1418 1419 1419 if ( !$source_topic = get_post( $from_reply->post_parent ) )1420 if ( !$source_topic = bbp_get_topic( $from_reply->post_parent ) ) 1420 1421 $bbp->errors->add( 'bbp_split_topic_source_not_found', __( '<strong>ERROR</strong>: The topic you want to split was not found!', 'bbpress' ) ); 1421 1422 … … 1435 1436 $bbp->errors->add( 'bbp_split_topic_destination_id', __( '<strong>ERROR</strong>: Destination topic ID not found!', 'bbpress' ) ); 1436 1437 1437 if ( !$destination_topic = get_post( $destination_topic_id ) )1438 if ( !$destination_topic = bbp_get_topic( $destination_topic_id ) ) 1438 1439 $bbp->errors->add( 'bbp_split_topic_destination_not_found', __( '<strong>ERROR</strong>: The topic you want to split to was not found!', 'bbpress' ) ); 1439 1440 … … 1462 1463 1463 1464 // Shouldn't happen 1464 if ( false == $destination_topic_id || is_wp_error( $destination_topic_id ) || !$destination_topic = get_post( $destination_topic_id ) )1465 if ( false == $destination_topic_id || is_wp_error( $destination_topic_id ) || !$destination_topic = bbp_get_topic( $destination_topic_id ) ) 1465 1466 $bbp->errors->add( 'bbp_split_topic_destination_reply', __( '<strong>ERROR</strong>: There was a problem converting the reply into the topic, please try again!', 'bbpress' ) ); 1466 1467 … … 2136 2137 * @since bbPress (r2727) 2137 2138 * 2138 * @uses get_post() To get the topic2139 * @uses bbp_get_topic() To get the topic 2139 2140 * @uses current_user_can() To check if the user is capable of editing or 2140 2141 * deleting the topic … … 2170 2171 2171 2172 // Make sure topic exists 2172 if ( !$topic = get_post( $topic_id ) )2173 if ( !$topic = bbp_get_topic( $topic_id ) ) 2173 2174 return; 2174 2175 … … 2272 2273 * @since bbPress (r2740) 2273 2274 * 2274 * @uses get_post() To get the reply2275 * @uses bbp_get_reply() To get the reply 2275 2276 * @uses current_user_can() To check if the user is capable of editing or 2276 2277 * deleting the reply … … 2301 2302 2302 2303 // Make sure reply exists 2303 if ( !$reply = get_post( $reply_id ) )2304 if ( !$reply = bbp_get_reply( $reply_id ) ) 2304 2305 return; 2305 2306 … … 2458 2459 */ 2459 2460 function bbp_is_favorites_active() { 2460 return (bool) get_option( '_bbp_enable_favorites' );2461 return (bool) get_option( '_bbp_enable_favorites', true ); 2461 2462 } 2462 2463 … … 2610 2611 * @param int $reply_id ID of the newly made reply 2611 2612 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active 2612 * @uses get_post() To get the topic and reply 2613 * @uses bbp_get_reply() To get the reply 2614 * @uses bbp_get_topic() To get the reply's topic 2613 2615 * @uses get_the_author_meta() To get the author's display name 2614 2616 * @uses do_action() Calls 'bbp_pre_notify_subscribers' with the reply id and … … 2632 2634 return false; 2633 2635 2634 if ( !$reply = get_post( $reply_id ) )2636 if ( !$reply = bbp_get_reply( $reply_id ) ) 2635 2637 return false; 2636 2638 … … 2638 2640 return false; 2639 2641 2640 if ( !$topic = get_post( $reply->post_parent ) )2642 if ( !$topic = bbp_get_topic( $reply->post_parent ) ) 2641 2643 return false; 2642 2644 -
branches/plugin/bbp-includes/bbp-options.php
r2786 r2787 41 41 42 42 // Topics per page 43 '_bbp_topics_per_page' => ' 20',43 '_bbp_topics_per_page' => '15', 44 44 45 45 // Replies per page 46 '_bbp_replies_per_page' => ' 20',46 '_bbp_replies_per_page' => '15', 47 47 48 48 /** SLUGS *************************************************************/ -
branches/plugin/bbp-includes/bbp-reply-template.php
r2782 r2787 175 175 return apply_filters( 'bbp_get_reply_id', (int) $bbp_reply_id ); 176 176 } 177 178 /** 179 * Gets a reply 180 * 181 * @since bbPress (r2787) 182 * 183 * @param int|object $reply reply id or reply object 184 * @param string $output Optional. OBJECT, ARRAY_A, or ARRAY_N. Default = OBJECT 185 * @param string $filter Optional Sanitation filter. See {@link sanitize_post()} 186 * @uses get_post() To get the reply 187 * @return mixed Null if error or reply (in specified form) if success 188 */ 189 function bbp_get_reply( $reply, $output = OBJECT, $filter = 'raw' ) { 190 global $bbp; 191 192 if ( empty( $reply ) || is_numeric( $reply ) ) 193 $reply = bbp_get_reply_id( $reply ); 194 195 if ( !$reply = get_post( $reply, OBJECT, $filter ) ) 196 return $reply; 197 198 if ( $bbp->reply_id !== $reply->post_type ) 199 return null; 200 201 if ( $output == OBJECT ) { 202 return $reply; 203 204 } elseif ( $output == ARRAY_A ) { 205 $_reply = get_object_vars( $reply ); 206 return $_reply; 207 208 } elseif ( $output == ARRAY_N ) { 209 $_reply = array_values( get_object_vars( $reply ) ); 210 return $_reply; 211 212 } 213 214 return $reply; 215 } 177 216 178 217 /** … … 1100 1139 * - edit_text: Edit text. Defaults to 'Edit' 1101 1140 * @uses bbp_get_reply_id() To get the reply id 1102 * @uses get_post() To get the reply1141 * @uses bbp_get_reply() To get the reply 1103 1142 * @uses current_user_can() To check if the current user can edit the 1104 1143 * reply … … 1119 1158 extract( $r ); 1120 1159 1121 $reply = get_post( bbp_get_reply_id( (int) $id ) );1160 $reply = bbp_get_reply( bbp_get_reply_id( (int) $id ) ); 1122 1161 1123 1162 if ( empty( $reply ) || !current_user_can( 'edit_reply', $reply->ID ) ) … … 1148 1187 * @param int $reply_id Optional. Reply id 1149 1188 * @uses bbp_get_reply_id() To get the reply id 1150 * @uses get_post() To get the reply1189 * @uses bbp_get_reply() To get the reply 1151 1190 * @uses add_query_arg() To add custom args to the url 1152 1191 * @uses home_url() To get the home url … … 1158 1197 global $wp_rewrite, $bbp; 1159 1198 1160 if ( !$reply = get_post( bbp_get_reply_id( $reply_id ) ) )1199 if ( !$reply = bbp_get_reply( bbp_get_reply_id( $reply_id ) ) ) 1161 1200 return; 1162 1201 … … 1197 1236 * - delete_text: Delete text 1198 1237 * @uses bbp_get_reply_id() To get the reply id 1199 * @uses get_post() To get the reply1238 * @uses bbp_get_reply() To get the reply 1200 1239 * @uses current_user_can() To check if the current user can delete the 1201 1240 * reply … … 1224 1263 1225 1264 $actions = array(); 1226 $reply = get_post( bbp_get_reply_id( (int) $id ) );1265 $reply = bbp_get_reply( bbp_get_reply_id( (int) $id ) ); 1227 1266 1228 1267 if ( empty( $reply ) || !current_user_can( 'delete_reply', $reply->ID ) ) … … 1269 1308 * - unspam_text: Unspam text 1270 1309 * @uses bbp_get_reply_id() To get the reply id 1271 * @uses get_post() To get the reply1310 * @uses bbp_get_reply() To get the reply 1272 1311 * @uses current_user_can() To check if the current user can edit the 1273 1312 * reply … … 1293 1332 extract( $r ); 1294 1333 1295 $reply = get_post( bbp_get_reply_id( (int) $id ) );1334 $reply = bbp_get_reply( bbp_get_reply_id( (int) $id ) ); 1296 1335 1297 1336 if ( empty( $reply ) || !current_user_can( 'moderate', $reply->ID ) ) … … 1334 1373 * - split_title: Split title attribute 1335 1374 * @uses bbp_get_reply_id() To get the reply id 1336 * @uses get_post() To get the reply1375 * @uses bbp_get_reply() To get the reply 1337 1376 * @uses current_user_can() To check if the current user can edit the 1338 1377 * topic … … 1358 1397 extract( $r ); 1359 1398 1360 $reply = get_post( bbp_get_reply_id( (int) $id ) );1399 $reply = bbp_get_reply( bbp_get_reply_id( (int) $id ) ); 1361 1400 1362 1401 if ( empty( $reply ) || !current_user_can( 'moderate', $reply->post_parent ) ) -
branches/plugin/bbp-includes/bbp-topic-template.php
r2786 r2787 275 275 return apply_filters( 'bbp_get_topic_id', (int) $bbp_topic_id ); 276 276 } 277 278 /** 279 * Gets a topic 280 * 281 * @since bbPress (r2787) 282 * 283 * @param int|object $topic Topic id or topic object 284 * @param string $output Optional. OBJECT, ARRAY_A, or ARRAY_N. Default = OBJECT 285 * @param string $filter Optional Sanitation filter. See {@link sanitize_post()} 286 * @uses get_post() To get the topic 287 * @return mixed Null if error or topic (in specified form) if success 288 */ 289 function bbp_get_topic( $topic, $output = OBJECT, $filter = 'raw' ) { 290 global $bbp; 291 292 if ( empty( $topic ) || is_numeric( $topic ) ) 293 $topic = bbp_get_topic_id( $topic ); 294 295 if ( !$topic = get_post( $topic, OBJECT, $filter ) ) 296 return $topic; 297 298 if ( $bbp->topic_id !== $topic->post_type ) 299 return null; 300 301 if ( $output == OBJECT ) { 302 return $topic; 303 304 } elseif ( $output == ARRAY_A ) { 305 $_topic = get_object_vars( $topic ); 306 return $_topic; 307 308 } elseif ( $output == ARRAY_N ) { 309 $_topic = array_values( get_object_vars( $topic ) ); 310 return $_topic; 311 312 } 313 314 return $topic; 315 } 277 316 278 317 /** … … 1282 1321 * @param int $topic_id Optional. Topic id 1283 1322 * @uses bbp_get_topic_id() To get the topic id 1284 * @uses get_post() To get the topic1323 * @uses bbp_get_topic() To get the topic 1285 1324 * @uses bbp_get_topic_reply_count() To get the topic reply count 1286 1325 * @uses bbp_get_topic_permalink() To get the topic permalink … … 1297 1336 global $bbp; 1298 1337 1299 $topic = get_post( bbp_get_topic_id( (int) $topic_id ) );1338 $topic = bbp_get_topic( bbp_get_topic_id( (int) $topic_id ) ); 1300 1339 $topic_id = $topic->ID; 1301 1340 $replies = bbp_get_topic_reply_count( $topic_id ); … … 1616 1655 * - edit_text: Edit text 1617 1656 * @uses bbp_get_topic_id() To get the topic id 1618 * @uses get_post() To get the topic1657 * @uses bbp_get_topic() To get the topic 1619 1658 * @uses current_user_can() To check if the current user can edit the 1620 1659 * topic … … 1635 1674 extract( $r ); 1636 1675 1637 $topic = get_post( bbp_get_topic_id( (int) $id ) );1676 $topic = bbp_get_topic( bbp_get_topic_id( (int) $id ) ); 1638 1677 1639 1678 if ( empty( $topic ) || !current_user_can( 'edit_topic', $topic->ID ) ) … … 1664 1703 * @param int $topic_id Optional. Topic id 1665 1704 * @uses bbp_get_topic_id() To get the topic id 1666 * @uses get_post() To get the topic1705 * @uses bbp_get_topic() To get the topic 1667 1706 * @uses add_query_arg() To add custom args to the url 1668 1707 * @uses home_url() To get the home url … … 1674 1713 global $wp_rewrite, $bbp; 1675 1714 1676 if ( !$topic = get_post( bbp_get_topic_id( $topic_id ) ) )1715 if ( !$topic = bbp_get_topic( bbp_get_topic_id( $topic_id ) ) ) 1677 1716 return; 1678 1717 … … 1713 1752 * - delete_text: Delete text 1714 1753 * @uses bbp_get_topic_id() To get the topic id 1715 * @uses get_post() To get the topic1754 * @uses bbp_get_topic() To get the topic 1716 1755 * @uses current_user_can() To check if the current user can delete the 1717 1756 * topic … … 1740 1779 1741 1780 $actions = array(); 1742 $topic = get_post( bbp_get_topic_id( (int) $id ) );1781 $topic = bbp_get_topic( bbp_get_topic_id( (int) $id ) ); 1743 1782 1744 1783 if ( empty( $topic ) || !current_user_can( 'delete_topic', $topic->ID ) ) … … 1785 1824 * - open_text: Open text 1786 1825 * @uses bbp_get_topic_id() To get the topic id 1787 * @uses get_post() To get the topic1826 * @uses bbp_get_topic() To get the topic 1788 1827 * @uses current_user_can() To check if the current user can edit the 1789 1828 * topic … … 1809 1848 extract( $r ); 1810 1849 1811 $topic = get_post( bbp_get_topic_id( (int) $id ) );1850 $topic = bbp_get_topic( bbp_get_topic_id( (int) $id ) ); 1812 1851 1813 1852 if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) … … 1847 1886 * - super_text: Stick to front text 1848 1887 * @uses bbp_get_topic_id() To get the topic id 1849 * @uses get_post() To get the topic1888 * @uses bbp_get_topic() To get the topic 1850 1889 * @uses current_user_can() To check if the current user can edit the 1851 1890 * topic … … 1871 1910 extract( $r ); 1872 1911 1873 $topic = get_post( bbp_get_topic_id( (int) $id ) );1912 $topic = bbp_get_topic( bbp_get_topic_id( (int) $id ) ); 1874 1913 1875 1914 if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) … … 1918 1957 * - link_after: After the link 1919 1958 * - merge_text: Merge text 1959 * @uses bbp_get_topic_id() To get the topic id 1960 * @uses bbp_get_topic() To get the topic 1920 1961 * @uses bbp_get_topic_edit_url() To get the topic edit url 1921 1962 * @uses add_query_arg() To add custom args to the url … … 1936 1977 extract( $r ); 1937 1978 1938 $topic = get_post( bbp_get_topic_id( (int) $id ) );1979 $topic = bbp_get_topic( bbp_get_topic_id( (int) $id ) ); 1939 1980 1940 1981 if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) … … 1970 2011 * - unspam_text: Unspam text 1971 2012 * @uses bbp_get_topic_id() To get the topic id 1972 * @uses get_post() To get the topic2013 * @uses bbp_get_topic() To get the topic 1973 2014 * @uses current_user_can() To check if the current user can edit the 1974 2015 * topic … … 1994 2035 extract( $r ); 1995 2036 1996 $topic = get_post( bbp_get_topic_id( (int) $id ) );2037 $topic = bbp_get_topic( bbp_get_topic_id( (int) $id ) ); 1997 2038 1998 2039 if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) ) -
branches/plugin/bbp-includes/bbp-users.php
r2780 r2787 195 195 * @uses bbp_get_user_id() To get the user id 196 196 * @uses bbp_get_user_favorites_topic_ids() To get the user favorites 197 * @uses get_post() To get the topic197 * @uses bbp_get_topic() To get the topic 198 198 * @uses bbp_get_topic_id() To get the topic id 199 199 * @uses apply_filters() Calls 'bbp_is_user_favorite' with the bool, user id, … … 210 210 211 211 if ( !empty( $topic_id ) ) { 212 $ post = get_post( $topic_id );213 $topic_id = $post->ID;212 $topic = bbp_get_topic( $topic_id ); 213 $topic_id = !empty( $topic ) ? $topic->ID : 0; 214 214 } elseif ( !$topic_id = bbp_get_topic_id() ) { 215 215 if ( empty( $post ) ) … … 246 246 $favorites = (array) bbp_get_user_favorites_topic_ids( $user_id ); 247 247 248 if ( !$topic = get_post( $topic_id ) )248 if ( !$topic = bbp_get_topic( $topic_id ) ) 249 249 return false; 250 250 … … 388 388 * @uses bbp_get_user_id() To get the user id 389 389 * @uses bbp_get_user_subscribed_topic_ids() To get the user's subscriptions 390 * @uses get_post() To get the topic390 * @uses bbp_get_topic() To get the topic 391 391 * @uses bbp_get_topic_id() To get the topic id 392 392 * @uses apply_filters() Calls 'bbp_is_user_subscribed' with the bool, user id, … … 403 403 404 404 if ( !empty( $topic_id ) ) { 405 $ post = get_post( $topic_id );406 $topic_id = $post->ID;405 $topic = bbp_get_topic( $topic_id ); 406 $topic_id = !empty( $topic ) ? $topic->ID : 0; 407 407 } elseif ( !$topic_id = bbp_get_topic_id() ) { 408 408 if ( empty( $post ) ) … … 429 429 * @param int $topic_id Optional. Topic id 430 430 * @uses bbp_get_user_subscribed_topic_ids() To get the user's subscriptions 431 * @uses get_post() To get the topic431 * @uses bbp_get_topic() To get the topic 432 432 * @uses update_user_meta() To update the user's subscriptions 433 433 * @uses do_action() Calls 'bbp_add_user_subscription' with the user & topic id … … 440 440 $subscriptions = (array) bbp_get_user_subscribed_topic_ids( $user_id ); 441 441 442 if ( !$topic = get_post( $topic_id ) )442 if ( !$topic = bbp_get_topic( $topic_id ) ) 443 443 return false; 444 444 -
branches/plugin/bbp-themes/bbp-twentyten/functions.php
r2758 r2787 32 32 * @uses bbp_get_current_user_id() To get the current user id 33 33 * @uses current_user_can() To check if the current user can edit the user 34 * @uses get_post() To get the topic34 * @uses bbp_get_topic() To get the topic 35 35 * @uses check_ajax_referer() To verify the nonce & check the referer 36 36 * @uses bbp_is_user_favorite() To check if the topic is user's favorite … … 45 45 die( '-1' ); 46 46 47 if ( !$topic = get_post( $id ) )47 if ( !$topic = bbp_get_topic( $id ) ) 48 48 die( '0' ); 49 49 … … 69 69 * @uses bbp_get_current_user_id() To get the current user id 70 70 * @uses current_user_can() To check if the current user can edit the user 71 * @uses get_post() To get the topic71 * @uses bbp_get_topic() To get the topic 72 72 * @uses check_ajax_referer() To verify the nonce & check the referer 73 73 * @uses bbp_is_user_subscribed() To check if the topic is in user's … … 87 87 die( '-1' ); 88 88 89 if ( !$topic = get_post( $id ) )89 if ( !$topic = bbp_get_topic( $id ) ) 90 90 die( '0' ); 91 91
Note: See TracChangeset
for help on using the changeset viewer.