Changeset 2746
- Timestamp:
- 01/05/2011 06:20:46 AM (15 years ago)
- Location:
- branches/plugin
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-admin/bbp-admin.php
r2745 r2746 65 65 add_filter( 'manage_' . $bbp->forum_id . '_posts_columns', array( $this, 'forums_column_headers' ) ); 66 66 67 // Forum metabox actions 68 add_action( 'add_meta_boxes', array( $this, 'forum_attributes_metabox' ) ); 69 add_action( 'save_post', array( $this, 'forum_attributes_metabox_save' ) ); 70 67 71 // Forum columns (in page row) 68 72 add_action( 'manage_pages_custom_column', array( $this, 'forums_column_data' ), 10, 2 ); … … 79 83 80 84 // Topic metabox actions 81 add_action( 'ad min_menu', array( $this, 'topic_parent_metabox' ) );82 add_action( 'save_post', array( $this, 'topic_ parent_metabox_save' ) );85 add_action( 'add_meta_boxes', array( $this, 'topic_attributes_metabox' ) ); 86 add_action( 'save_post', array( $this, 'topic_attributes_metabox_save' ) ); 83 87 84 88 // Check if there are any bbp_toggle_topic_* requests on admin_init, also have a message displayed 85 add_action( 'bbp_admin_init', array( $this, 'toggle_topic' ) );89 add_action( 'bbp_admin_init', array( $this, 'toggle_topic' ) ); 86 90 add_action( 'admin_notices', array( $this, 'toggle_topic_notice' ) ); 87 91 … … 95 99 add_filter( 'post_row_actions', array( $this, 'replies_row_actions' ), 10, 2 ); 96 100 97 // Topic reply metabox actions98 add_action( 'ad min_menu', array( $this, 'reply_parent_metabox' ) );99 add_action( 'save_post', array( $this, 'reply_ parent_metabox_save' ) );101 // Reply metabox actions 102 add_action( 'add_meta_boxes', array( $this, 'reply_attributes_metabox' ) ); 103 add_action( 'save_post', array( $this, 'reply_attributes_metabox_save' ) ); 100 104 101 105 // Register bbPress admin style … … 103 107 104 108 // Check if there are any bbp_toggle_reply_* requests on admin_init, also have a message displayed 105 add_action( 'bbp_admin_init', array( $this, 'toggle_reply' ) );109 add_action( 'bbp_admin_init', array( $this, 'toggle_reply' ) ); 106 110 add_action( 'admin_notices', array( $this, 'toggle_reply_notice' ) ); 107 111 } … … 215 219 216 220 /** 217 * topic_parent_metabox ()218 * 219 * Add the topic parentmetabox221 * forum_attributes_metabox () 222 * 223 * Add the forum attributes metabox 220 224 * 221 225 * @uses add_meta_box 222 226 */ 223 function topic_parent_metabox () {227 function forum_attributes_metabox () { 224 228 global $bbp; 225 229 226 230 add_meta_box ( 227 'bbp_topic_parent_id', 228 __( 'Forum', 'bbpress' ), 231 'bbp_forum_attributes', 232 __( 'Forum Attributes', 'bbpress' ), 233 'bbp_forum_metabox', 234 $bbp->forum_id, 235 'side', 236 'high' 237 ); 238 239 do_action( 'bbp_forum_attributes_metabox' ); 240 } 241 242 /** 243 * forum_attributes_metabox_save () 244 * 245 * Pass the forum attributes for processing 246 * 247 * @param int $forum_id 248 * @return int 249 */ 250 function forum_attributes_metabox_save ( $forum_id ) { 251 global $bbp; 252 253 if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) 254 return $forum_id; 255 256 if ( $bbp->forum_id != get_post_field( 'post_type', $forum_id ) ) 257 return $forum_id; 258 259 if ( !current_user_can( 'edit_forum', $forum_id ) ) 260 return $forum_id; 261 262 // Closed? 263 if ( !empty( $_POST['bbp_forum_status'] ) && in_array( $_POST['bbp_forum_status'], array( 'open', 'closed' ) ) ) { 264 if ( 'closed' == $_POST['bbp_forum_status'] && !bbp_is_forum_closed( $forum_id, false ) ) 265 bbp_close_forum( $forum_id ); 266 elseif ( 'open' == $_POST['bbp_forum_status'] && bbp_is_forum_closed( $forum_id, false ) ) 267 bbp_open_forum( $forum_id ); 268 } 269 270 // Category? 271 if ( !empty( $_POST['bbp_forum_type'] ) && in_array( $_POST['bbp_forum_type'], array( 'forum', 'category' ) ) ) { 272 if ( 'category' == $_POST['bbp_forum_type'] && !bbp_is_forum_category( $forum_id ) ) 273 bbp_categorize_forum( $forum_id ); 274 elseif ( 'forum' == $_POST['bbp_forum_type'] && bbp_is_forum_category( $forum_id ) ) 275 bbp_normalize_forum( $forum_id ); 276 } 277 278 // Private? 279 if ( !empty( $_POST['bbp_forum_visibility'] ) && in_array( $_POST['bbp_forum_visibility'], array( 'public', 'private' ) ) ) { 280 if ( 'private' == $_POST['bbp_forum_visibility'] && !bbp_is_forum_private( $forum_id, false ) ) 281 bbp_privatize_forum( $forum_id ); 282 elseif ( 'public' == $_POST['bbp_forum_visibility'] ) 283 bbp_publicize_forum( $forum_id ); 284 } 285 286 do_action( 'bbp_forum_attributes_metabox_save' ); 287 288 return $forum_id; 289 } 290 291 /** 292 * topic_attributes_metabox () 293 * 294 * Add the topic attributes metabox 295 * 296 * @uses add_meta_box 297 */ 298 function topic_attributes_metabox () { 299 global $bbp; 300 301 add_meta_box ( 302 'bbp_topic_attributes', 303 __( 'Topic Attributes', 'bbpress' ), 229 304 'bbp_topic_metabox', 230 305 $bbp->topic_id, 231 'normal' 306 'side', 307 'high' 232 308 ); 233 309 234 do_action( 'bbp_topic_ parent_metabox' );235 } 236 237 /** 238 * topic_ parent_metabox_save ()239 * 240 * Pass the topic post parent idfor processing241 * 242 * @param int $ post_id310 do_action( 'bbp_topic_attributes_metabox' ); 311 } 312 313 /** 314 * topic_attributes_metabox_save () 315 * 316 * Pass the topic attributes for processing 317 * 318 * @param int $topic_id 243 319 * @return int 244 320 */ 245 function topic_ parent_metabox_save ( $post_id ) {321 function topic_attributes_metabox_save ( $topic_id ) { 246 322 if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) 247 return $ post_id;248 249 if ( !current_user_can( 'edit_ post', $post_id ) )250 return $ post_id;323 return $topic_id; 324 325 if ( !current_user_can( 'edit_topic', $topic_id ) ) 326 return $topic_id; 251 327 252 328 // OK, we're authenticated: we need to find and save the data 253 $parent_id = isset( $_ POST['parent_id'] ) ? $_POST['parent_id'] : 0;254 255 do_action( 'bbp_topic_ parent_metabox_save' );329 $parent_id = isset( $_topic['parent_id'] ) ? $_topic['parent_id'] : 0; 330 331 do_action( 'bbp_topic_attributes_metabox_save' ); 256 332 257 333 return $parent_id; … … 259 335 260 336 /** 261 * reply_ parent_metabox ()262 * 263 * Add the topic reply parentmetabox264 */ 265 function reply_ parent_metabox () {337 * reply_attributes_metabox () 338 * 339 * Add the reply attributes metabox 340 */ 341 function reply_attributes_metabox () { 266 342 global $bbp; 267 343 268 344 add_meta_box ( 269 'bbp_reply_ parent_id',270 __( ' Topic', 'bbpress' ),345 'bbp_reply_attributes', 346 __( 'Reply Attributes', 'bbpress' ), 271 347 'bbp_reply_metabox', 272 348 $bbp->reply_id, 273 'normal' 349 'side', 350 'high' 274 351 ); 275 352 276 do_action( 'bbp_reply_ parent_metabox' );277 } 278 279 /** 280 * reply_ parent_metabox_save ()281 * 282 * Pass the topic reply post parent idfor processing283 * 284 * @param int $ post_id353 do_action( 'bbp_reply_attributes_metabox' ); 354 } 355 356 /** 357 * reply_attributes_metabox_save () 358 * 359 * Pass the reply attributes for processing 360 * 361 * @param int $reply_id 285 362 * @return int 286 363 */ 287 function reply_ parent_metabox_save ( $post_id ) {364 function reply_attributes_metabox_save ( $reply_id ) { 288 365 if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) 289 return $ post_id;290 291 if ( !current_user_can( 'edit_ post', $post_id ) )292 return $ post_id;366 return $reply_id; 367 368 if ( !current_user_can( 'edit_reply', $reply_id ) ) 369 return $reply_id; 293 370 294 371 // OK, we're authenticated: we need to find and save the data 295 $parent_id = isset( $_ POST['parent_id'] ) ? $_POST['parent_id'] : 0;296 297 do_action( 'bbp_reply_ parent_metabox_save' );372 $parent_id = isset( $_reply['parent_id'] ) ? $_reply['parent_id'] : 0; 373 374 do_action( 'bbp_reply_attributes_metabox_save' ); 298 375 299 376 return $parent_id; … … 306 383 */ 307 384 function admin_head () { 308 global $bbp ;385 global $bbp, $post; 309 386 310 387 // Icons for top level admin menus … … 351 428 background: url(<?php echo $icon32_url; ?>) no-repeat -4px -180px; 352 429 } 430 431 <?php if ( $post->post_type == $bbp->forum_id ) : ?> 432 433 #misc-publishing-actions, #save-post { display: none; } 434 strong.label { display: inline-block; width: 60px; } 435 #bbp_forum_attributes hr { border-style: solid; border-width: 1px; border-color: #ccc #fff #fff #ccc; } 436 437 <?php endif; ?> 353 438 354 439 <?php if ( bbp_is_forum() || bbp_is_topic() || bbp_is_reply() ) : ?> … … 379 464 */ 380 465 function user_profile_update ( $user_id ) { 381 return false;382 383 466 // Add extra actions to bbPress profile update 384 467 do_action( 'bbp_user_profile_update' ); 468 469 return false; 385 470 } 386 471 … … 733 818 the_content(); 734 819 735 // Show the 'close' and 'open' link on published topics only 736 if ( in_array( $topic->post_status, array( 'publish', $bbp->spam_status_id ) ) ) { 820 // Show view link if it's not set, the topic is trashed and the user can view trashed topics 821 if ( empty( $actions['view'] ) && 'trash' == $topic->post_status && current_user_can( 'view_trash' ) ) 822 $actions['view'] = '<a href="' . bbp_get_topic_permalink( $topic->ID ) . '" title="' . esc_attr( sprintf( __( 'View “%s”', 'bbpress' ), bbp_get_topic_title( $topic->ID ) ) ) . '" rel="permalink">' . __( 'View', 'bbpress' ) . '</a>'; 823 824 // Show the 'close' and 'open' link on published and closed posts only 825 if ( in_array( $topic->post_status, array( 'publish', $bbp->closed_status_id ) ) ) { 737 826 $close_uri = esc_url( wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_close' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed' ) ) ), 'close-topic_' . $topic->ID ) ); 738 827 if ( bbp_is_topic_open( $topic->ID ) ) … … 985 1074 unset( $actions['inline hide-if-no-js'] ); 986 1075 1076 // Show view link if it's not set, the reply is trashed and the user can view trashed replies 1077 if ( empty( $actions['view'] ) && 'trash' == $reply->post_status && current_user_can( 'view_trash' ) ) 1078 $actions['view'] = '<a href="' . bbp_get_reply_permalink( $reply->ID ) . '" title="' . esc_attr( sprintf( __( 'View “%s”', 'bbpress' ), bbp_get_reply_title( $reply->ID ) ) ) . '" rel="permalink">' . __( 'View', 'bbpress' ) . '</a>'; 1079 987 1080 the_content(); 988 1081 … … 1034 1127 * 1035 1128 * @package bbPress 1036 * @subpackage Template Tags1129 * @subpackage Admin 1037 1130 * @since bbPress (r2464) 1038 1131 * … … 1049 1142 1050 1143 /** 1144 * bbp_forum_metabox () 1145 * 1146 * The metabox that holds all of the additional forum information 1147 * 1148 * @package bbPress 1149 * @subpackage Admin 1150 * @since bbPress (r2744) 1151 */ 1152 function bbp_forum_metabox () { 1153 global $bbp, $post; 1154 1155 /** TYPE ******************************************************************/ 1156 $forum['type'] = array( 1157 'forum' => __( 'Forum', 'bbpress' ), 1158 'category' => __( 'Category', 'bbpress' ) 1159 ); 1160 $type_output = '<select name="bbp_forum_type" id="bbp_forum_type_select">' . "\n"; 1161 1162 foreach( $forum['type'] as $value => $label ) 1163 $type_output .= "\t" . '<option value="' . $value . '"' . selected( bbp_is_forum_category( $post->ID ) ? 'category' : 'forum', $value, false ) . '>' . esc_html( $label ) . '</option>' . "\n"; 1164 1165 $type_output .= '</select>'; 1166 1167 /** STATUS ****************************************************************/ 1168 $forum['status'] = array( 1169 'open' => __( 'Open', 'bbpress' ), 1170 'closed' => __( 'Closed', 'bbpress' ) 1171 ); 1172 $status_output = '<select name="bbp_forum_status" id="bbp_forum_status_select">' . "\n"; 1173 1174 foreach( $forum['status'] as $value => $label ) 1175 $status_output .= "\t" . '<option value="' . $value . '"' . selected( bbp_is_forum_closed( $post->ID, false ) ? 'closed' : 'open', $value, false ) . '>' . esc_html( $label ) . '</option>' . "\n"; 1176 1177 $status_output .= '</select>'; 1178 1179 /** VISIBILITY ************************************************************/ 1180 $forum['visibility'] = array( 1181 'public' => __( 'Public', 'bbpress' ), 1182 'private' => __( 'Private', 'bbpress' ) 1183 ); 1184 $visibility_output = '<select name="bbp_forum_visibility" id="bbp_forum_visibility_select">' . "\n"; 1185 1186 foreach( $forum['visibility'] as $value => $label ) 1187 $visibility_output .= "\t" . '<option value="' . $value . '"' . selected( bbp_is_forum_private( $post->ID, false ) ? 'private' : 'public', $value, false ) . '>' . esc_html( $label ) . '</option>' . "\n"; 1188 1189 $visibility_output .= '</select>'; 1190 1191 /** OUTPUT ****************************************************************/ ?> 1192 1193 <p> 1194 <strong class="label"><?php _e( 'Type:', 'bbpress' ); ?></strong> 1195 <label class="screen-reader-text" for="bbp_forum_type_select"><?php _e( 'Type:', 'bbpress' ) ?></label> 1196 <?php echo $type_output; ?> 1197 </p> 1198 1199 <p> 1200 <strong class="label"><?php _e( 'Status:', 'bbpress' ); ?></strong> 1201 <label class="screen-reader-text" for="bbp_forum_status_select"><?php _e( 'Status:', 'bbpress' ) ?></label> 1202 <?php echo $status_output; ?> 1203 </p> 1204 1205 <p> 1206 <strong class="label"><?php _e( 'Visibility:', 'bbpress' ); ?></strong> 1207 <label class="screen-reader-text" for="bbp_forum_visibility_select"><?php _e( 'Visibility:', 'bbpress' ) ?></label> 1208 <?php echo $visibility_output; ?> 1209 </p> 1210 1211 <hr /> 1212 1213 <p> 1214 <strong class="label"><?php _e( 'Parent:', 'bbpress' ); ?></strong> 1215 <label class="screen-reader-text" for="parent_id"><?php _e( 'Forum Parent', 'bbpress' ); ?></label> 1216 1217 <?php 1218 bbp_dropdown( array( 1219 'exclude' => $post->ID, 1220 'selected' => $post->post_parent, 1221 'show_none' => __( '(No Parent)', 'bbpress' ), 1222 'select_id' => 'parent_id', 1223 'disable_categories' => false 1224 ) ); 1225 ?> 1226 1227 </p> 1228 1229 <p> 1230 <strong class="label"><?php _e( 'Order:', 'bbpress' ); ?></strong> 1231 <label class="screen-reader-text" for="menu_order"><?php _e( 'Forum Order', 'bbpress' ); ?></label> 1232 <input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo esc_attr( $post->menu_order ); ?>" /> 1233 </p> 1234 <?php 1235 1236 do_action( 'bbp_forum_metabox' ); 1237 } 1238 1239 /** 1051 1240 * bbp_topic_metabox () 1052 1241 * … … 1054 1243 * 1055 1244 * @package bbPress 1056 * @subpackage Template Tags1245 * @subpackage Admin 1057 1246 * @since bbPress (r2464) 1058 1247 * 1059 * @todo Alot ;)1060 1248 * @global object $post 1061 1249 */ … … 1064 1252 1065 1253 $args = array( 1066 'post_type' => $bbp->forum_id, 1067 'exclude_tree' => $post->ID, 1068 'selected' => $post->post_parent, 1069 'show_option_none' => __( '(No Forum)', 'bbpress' ), 1070 'sort_column' => 'menu_order, post_title', 1071 'child_of' => '0', 1254 'selected' => $post->post_parent, 1255 'select_id' => 'parent_id' 1072 1256 ); 1073 1257 1074 $posts = bbp_admin_dropdown ( 1075 __( 'Forum', 'bbpress' ), 1076 __( 'Forum', 'bbpress' ), 1077 __( 'There are no forums to reply to.', 'bbpress' ), 1078 $args 1079 ); 1080 1081 echo $posts; 1082 ?> 1083 <p><strong><?php _e( 'Topic Order', 'bbpress' ); ?></strong></p> 1084 <p><label class="screen-reader-text" for="menu_order"><?php _e( 'Topic Order', 'bbpress' ) ?></label><input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo esc_attr( $post->menu_order ); ?>" /></p> 1085 <p><?php if ( 'page' == $post->post_type ) _e( 'Need help? Use the Help tab in the upper right of your screen.' ); ?></p> 1258 ?> 1259 1260 <p> 1261 <strong><?php _e( 'Forum', 'bbpress' ); ?></strong> 1262 </p> 1263 1264 <p> 1265 <label class="screen-reader-text" for="parent_id"><?php _e( 'Forum', 'bbpress' ); ?></label> 1266 <?php bbp_dropdown( $args ); ?> 1267 </p> 1268 1269 <p> 1270 <strong><?php _e( 'Topic Order', 'bbpress' ); ?></strong> 1271 </p> 1272 1273 <p> 1274 <label class="screen-reader-text" for="menu_order"><?php _e( 'Topic Order', 'bbpress' ); ?></label> 1275 <input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo esc_attr( $post->menu_order ); ?>" /> 1276 </p> 1086 1277 <?php 1087 1278 … … 1092 1283 * bbp_reply_metabox () 1093 1284 * 1094 * The metabox that holds all of the additional topicinformation1285 * The metabox that holds all of the additional reply information 1095 1286 * 1096 1287 * @package bbPress 1097 * @subpackage Template Tags1288 * @subpackage Admin 1098 1289 * @since bbPress (r2464) 1099 1290 * 1100 * @todo Alot ;)1101 1291 * @global object $post 1102 1292 */ … … 1105 1295 1106 1296 $args = array( 1107 'post_type' => $bbp->topic_id, 1108 'exclude_tree' => $post->ID, 1109 'selected' => $post->post_parent, 1110 'show_option_none' => __( '(No Topic)', 'bbpress' ), 1111 'sort_column' => 'menu_order, post_title', 1112 'child_of' => '0', 1297 'post_type' => $bbp->topic_id, 1298 'selected' => $post->post_parent, 1299 'select_id' => 'parent_id' 1113 1300 ); 1114 1301 1115 $posts = bbp_admin_dropdown( 1116 __( 'Topic', 'bbpress' ), 1117 __( 'Topic', 'bbpress' ), 1118 __( 'There are no topics to reply to.', 'bbpress' ), 1119 $args 1120 ); 1121 1122 echo $posts; 1123 1124 do_action( 'bbp_topic_reply_metabox' ); 1125 } 1126 1127 /** 1128 * bbp_admin_dropdown () 1129 * 1130 * General wrapper for creating a drop down of selectable parents 1131 * 1132 * @package bbPress 1133 * @subpackage Template Tags 1134 * @since bbPress (r2464) 1135 * 1136 * @param string $title 1137 * @param string $sub_title 1138 * @param mixed $error 1139 * @param array $args 1140 */ 1141 function bbp_admin_dropdown ( $title, $sub_title, $error, $args = '' ) { 1142 1143 // The actual fields for data entry 1144 $posts = get_posts( $args ); 1145 1146 if ( !empty( $posts ) ) { 1147 $output = '<select name="parent_id" id="parent_id">'; 1148 $output .= '<option value="">' . __( '(No Parent)', 'bbpress' ) . '</option>'; 1149 $output .= walk_page_dropdown_tree( $posts, 0, $args ); 1150 $output .= '</select>'; 1151 } 1152 1153 $output = apply_filters( 'wp_dropdown_pages', $output ); 1154 1155 if ( !empty( $output ) ) : ?> 1156 <p><strong><?php echo $title; ?></strong></p> 1157 <label class="screen-reader-text" for="parent_id"><?php echo $sub_title; ?></label> 1158 <?php 1159 echo $output; 1160 else : 1161 ?> 1162 <p><strong><?php echo $error; ?></strong></p> 1163 <?php 1164 endif; 1302 ?> 1303 1304 <p> 1305 <strong><?php _e( 'Topic', 'bbpress' ); ?></strong> 1306 </p> 1307 1308 <p> 1309 <label class="screen-reader-text" for="parent_id"><?php _e( 'Topic', 'bbpress' ); ?></label> 1310 <?php bbp_dropdown( $args ); ?> 1311 </p> 1312 1313 <?php 1314 1315 do_action( 'bbp_reply_metabox' ); 1165 1316 } 1166 1317 … … 1170 1321 * Setup bbPress Admin 1171 1322 * 1172 * @global <type>$bbp1323 * @global object $bbp 1173 1324 */ 1174 1325 function bbp_admin() { -
branches/plugin/bbp-includes/bbp-caps.php
r2741 r2746 70 70 71 71 // Topic caps 72 $default->add_cap( 'publish_topics' );73 $default->add_cap( 'edit_topics' );74 75 // Reply caps 76 $default->add_cap( 'publish_replies' );77 $default->add_cap( 'edit_replies' );72 $default->add_cap( 'publish_topics' ); 73 $default->add_cap( 'edit_topics' ); 74 75 // Reply caps 76 $default->add_cap( 'publish_replies' ); 77 $default->add_cap( 'edit_replies' ); 78 78 79 79 // Topic tag caps … … 170 170 171 171 // Topic caps 172 $default->remove_cap( 'publish_topics' );173 $default->remove_cap( 'edit_topics' );172 $default->remove_cap( 'publish_topics' ); 173 $default->remove_cap( 'edit_topics' ); 174 174 175 175 // Reply caps -
branches/plugin/bbp-includes/bbp-classes.php
r2701 r2746 246 246 } 247 247 248 /** 249 * Create HTML dropdown list of bbPress forums/topics. 250 * 251 * @package bbPress 252 * @subpackage Classes 253 * 254 * @since bbPress (r2744) 255 * @uses Walker 256 */ 257 class BBP_Walker_Dropdown extends Walker { 258 /** 259 * @see Walker::$tree_type 260 * 261 * @since bbPress (r2744) 262 * 263 * @var string 264 */ 265 var $tree_type; 266 267 /** 268 * @see Walker::$db_fields 269 * 270 * @since bbPress (r2744) 271 * 272 * @var array 273 */ 274 var $db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' ); 275 276 /** 277 * Set the tree_type 278 * 279 * @since bbPress (r2744) 280 */ 281 function BBP_Walker_Dropdown() { 282 global $bbp; 283 284 $this->tree_type = $bbp->forum_id; 285 } 286 287 /** 288 * @see Walker::start_el() 289 * 290 * @since bbPress (r2744) 291 * 292 * @param string $output Passed by reference. Used to append additional content. 293 * @param object $post Post data object. 294 * @param int $depth Depth of post in reference to parent posts. Used for padding. 295 * @param array $args Uses 'selected' argument for selected post to set selected HTML attribute for option element. 296 */ 297 function start_el( &$output, $post, $depth, $args ) { 298 global $bbp; 299 300 $pad = str_repeat( ' ', $depth * 3 ); 301 $output .= "\t<option class=\"level-$depth\""; 302 303 // Disable the <option> if we're told to do so, the post type is bbp_forum and the forum is a category 304 if ( $args['disable_categories'] == true && $post->post_type == $bbp->forum_id && bbp_is_forum_category( $post->ID ) ) 305 $output .= ' disabled="disabled" value=""'; 306 else 307 $output .= ' value="' .$post->ID .'"' . selected( $args['selected'], $post->ID, false ); 308 309 $output .= '>'; 310 $title = esc_html( $post->post_title ); 311 $title = apply_filters( 'bbp_walker_dropdown_post_title', $post->post_title, $output, $post, $depth, $args ); 312 $output .= $pad . $title; 313 $output .= "</option>\n"; 314 } 315 } 316 248 317 endif; // class_exists check 249 318 -
branches/plugin/bbp-includes/bbp-forum-template.php
r2740 r2746 28 28 29 29 $r = wp_parse_args( $args, $default ); 30 31 // Don't show private forums to normal users 32 if ( !current_user_can( 'edit_others_forums' ) && empty( $r['meta_key'] ) && empty( $r['meta_value'] ) && empty( $r['meta_compare'] ) ) { 33 $r['meta_key'] = '_bbp_forum_visibility'; 34 $r['meta_value'] = 'public'; 35 $r['meta_compare'] = '=='; 36 } 30 37 31 38 $bbp->forum_query = new WP_Query( $r ); … … 293 300 * @since bbPress (r2705) 294 301 * 295 * @param int $forum_id302 * @param mixed $args All the arguments supported by {@link WP_Query} 296 303 * @return false if none, array of subs if yes 297 304 */ 298 function bbp_forum_has_sub_forums ( $ forum_id = 0) {305 function bbp_forum_has_sub_forums ( $args = '' ) { 299 306 global $bbp; 300 307 301 $forum_id = bbp_get_forum_id( $forum_id ); 302 $sub_forums = ''; 308 if ( is_numeric( $args ) ) 309 $args = array( 'post_parent' => $args ); 310 311 $default = array( 312 'post_parent' => 0, 313 'post_type' => $bbp->forum_id, 314 'sort_column' => 'menu_order, post_title' 315 ); 316 317 $r = wp_parse_args( $args, $default ); 318 319 $r['post_parent'] = bbp_get_forum_id( $r['post_parent'] ); 320 321 // Don't show private forums to normal users 322 if ( !current_user_can( 'edit_others_forums' ) && empty( $r['meta_key'] ) && empty( $r['meta_value'] ) && empty( $r['meta_compare'] ) ) { 323 $r['meta_key'] = '_bbp_forum_visibility'; 324 $r['meta_value'] = 'public'; 325 $r['meta_compare'] = '=='; 326 } 303 327 304 328 // No forum passed 305 if ( !empty( $forum_id ) ) 306 $sub_forums = get_pages( array( 'parent' => $forum_id, 'post_type' => $bbp->forum_id, 'child_of' => $forum_id, 'sort_column' => 'menu_order' ) ); 307 308 return apply_filters( 'bbp_forum_has_sub_forums', (array)$sub_forums, $forum_id ); 329 $sub_forums = !empty( $r['post_parent'] ) ? get_posts( $r ) : ''; 330 331 return apply_filters( 'bbp_forum_has_sub_forums', (array) $sub_forums, $args ); 309 332 } 310 333 … … 970 993 $forum_id = bbp_get_forum_id( $forum_id ); 971 994 972 return apply_filters( 'bbp_get_forum_status', get_post_status( $forum_id ) ); 973 } 995 return apply_filters( 'bbp_get_forum_status', get_post_meta( $forum_id, '_bbp_forum_status', true ) ); 996 } 997 998 /** 999 * Closes a forum 1000 * 1001 * @since bbPress (r2744) 1002 * 1003 * @param int $forum_id forum id 1004 * @uses wp_get_single_post() To get the forum 1005 * @uses do_action() Calls 'bbp_close_forum' with the forum id 1006 * @uses add_post_meta() To add the previous status to a meta 1007 * @uses wp_insert_post() To update the forum with the new status 1008 * @uses do_action() Calls 'bbp_opened_forum' with the forum id 1009 * @return mixed False or {@link WP_Error} on failure, forum id on success 1010 */ 1011 function bbp_close_forum( $forum_id = 0 ) { 1012 global $bbp; 1013 1014 if ( !$forum = wp_get_single_post( $forum_id, ARRAY_A ) ) 1015 return $forum; 1016 1017 do_action( 'bbp_close_forum', $forum_id ); 1018 1019 update_post_meta( $forum_id, '_bbp_forum_status', 'closed' ); 1020 1021 do_action( 'bbp_closed_forum', $forum_id ); 1022 1023 return $forum_id; 1024 } 1025 1026 /** 1027 * Opens a forum 1028 * 1029 * @since bbPress (r2744) 1030 * 1031 * @param int $forum_id forum id 1032 * @uses wp_get_single_post() To get the forum 1033 * @uses do_action() Calls 'bbp_open_forum' with the forum id 1034 * @uses get_post_meta() To get the previous status 1035 * @uses delete_post_meta() To delete the previous status meta 1036 * @uses wp_insert_post() To update the forum with the new status 1037 * @uses do_action() Calls 'bbp_opened_forum' with the forum id 1038 * @return mixed False or {@link WP_Error} on failure, forum id on success 1039 */ 1040 function bbp_open_forum( $forum_id = 0 ) { 1041 global $bbp; 1042 1043 if ( !$forum = wp_get_single_post( $forum_id, ARRAY_A ) ) 1044 return $forum; 1045 1046 do_action( 'bbp_open_forum', $forum_id ); 1047 1048 update_post_meta( $forum_id, '_bbp_forum_status', 'open' ); 1049 1050 do_action( 'bbp_opened_forum', $forum_id ); 1051 1052 return $forum_id; 1053 } 1054 1055 /** 1056 * Make the forum a category 1057 * 1058 * @since bbPress (r2744) 1059 * 1060 * @param int $forum_id Optional. Forum id 1061 * @uses update_post_meta() To update the forum category meta 1062 * @return bool False on failure, true on success 1063 */ 1064 function bbp_categorize_forum( $forum_id = 0 ) { 1065 return update_post_meta( $forum_id, '_bbp_forum_type', 'category' ); 1066 } 1067 1068 /** 1069 * Remove the category status from a forum 1070 * 1071 * @since bbPress (r2744) 1072 * 1073 * @param int $forum_id Optional. Forum id 1074 * @uses delete_post_meta() To delete the forum category meta 1075 * @return bool False on failure, true on success 1076 */ 1077 function bbp_normalize_forum( $forum_id = 0 ) { 1078 return update_post_meta( $forum_id, '_bbp_forum_type', 'forum' ); 1079 } 1080 1081 /** 1082 * Mark the forum as private 1083 * 1084 * @since bbPress (r2744) 1085 * 1086 * @param int $forum_id Optional. Forum id 1087 * @uses update_post_meta() To update the forum private meta 1088 * @return bool False on failure, true on success 1089 */ 1090 function bbp_privatize_forum( $forum_id = 0 ) { 1091 return update_post_meta( $forum_id, '_bbp_forum_visibility', 'private' ); 1092 } 1093 1094 /** 1095 * Unmark the forum as private 1096 * 1097 * @since bbPress (r2744) 1098 * 1099 * @param int $forum_id Optional. Forum id 1100 * @uses delete_post_meta() To delete the forum private meta 1101 * @return bool False on failure, true on success 1102 */ 1103 function bbp_publicize_forum( $forum_id = 0 ) { 1104 return update_post_meta( $forum_id, '_bbp_forum_visibility', 'public' ); 1105 } 1106 1107 /** 1108 * Is the forum a category? 1109 * 1110 * @since bbPress (r2744) 1111 * 1112 * @param int $forum_id Optional. Forum id 1113 * @uses get_post_meta() To get the forum category meta 1114 * @return bool Whether the forum is a category or not 1115 */ 1116 function bbp_is_forum_category( $forum_id = 0 ) { 1117 $forum_id = bbp_get_forum_id( $forum_id ); 1118 $type = get_post_meta( $forum_id, '_bbp_forum_type', true ); 1119 1120 if ( !empty( $type ) && 'category' == $type ) 1121 return true; 1122 1123 return false; 1124 } 1125 1126 /** 1127 * Is the forum open? 1128 * 1129 * @since bbPress (r2744) 1130 * @param int $forum_id Optional. Forum id 1131 * 1132 * @param int $forum_id Optional. Forum id 1133 * @uses bbp_is_forum_closed() To check if the forum is closed or not 1134 * @return bool Whether the forum is open or not 1135 */ 1136 function bbp_is_forum_open( $forum_id = 0 ) { 1137 return !bbp_is_forum_closed( $forum_id ); 1138 } 1139 1140 /** 1141 * Is the forum closed? 1142 * 1143 * @since bbPress (r2744) 1144 * 1145 * @param int $forum_id Optional. Forum id 1146 * @param bool $check_ancestors Check if the ancestors are closed (only 1147 * if they're a category) 1148 * @uses bbp_get_forum_status() To get the forum status 1149 * @uses bbp_get_forum_ancestors() To get the forum ancestors 1150 * @uses bbp_is_forum_category() To check if the forum is a category 1151 * @uses bbp_is_forum_closed() To check if the forum is closed 1152 * @return bool True if closed, false if not 1153 */ 1154 function bbp_is_forum_closed( $forum_id = 0, $check_ancestors = true ) { 1155 global $bbp; 1156 1157 $forum_id = bbp_get_forum_id( $forum_id ); 1158 1159 if ( $bbp->closed_status_id == bbp_get_forum_status( $forum_id ) ) 1160 return true; 1161 1162 if ( !empty( $check_ancestors ) ) { 1163 $ancestors = bbp_get_forum_ancestors( $forum_id ); 1164 1165 foreach ( (array) $ancestors as $ancestor ) { 1166 if ( bbp_is_forum_category( $ancestor, false ) && bbp_is_forum_closed( $ancestor, false ) ) 1167 return true; 1168 } 1169 } 1170 1171 return false; 1172 } 1173 1174 /** 1175 * Is the forum private? 1176 * 1177 * @since bbPress (r2744) 1178 * 1179 * @param int $forum_id Optional. Forum id 1180 * @param bool $check_ancestors Check if the ancestors are private (only if 1181 * they're a category) 1182 * @uses get_post_meta() To get the forum private meta 1183 * @uses bbp_get_forum_ancestors() To get the forum ancestors 1184 * @uses bbp_is_forum_category() To check if the forum is a category 1185 * @uses bbp_is_forum_closed() To check if the forum is closed 1186 * @return bool True if closed, false if not 1187 */ 1188 function bbp_is_forum_private( $forum_id = 0, $check_ancestors = true ) { 1189 global $bbp; 1190 1191 $forum_id = bbp_get_forum_id( $forum_id ); 1192 $visibility = get_post_meta( $forum_id, '_bbp_forum_visibility', true ); 1193 1194 if ( !empty( $visibility ) && 'private' == $visibility ) 1195 return true; 1196 1197 if ( !empty( $check_ancestors ) ) { 1198 $ancestors = bbp_get_forum_ancestors( $forum_id ); 1199 1200 foreach ( (array) $ancestors as $ancestor ) { 1201 if ( bbp_is_forum_private( $ancestor, false ) ) 1202 return true; 1203 } 1204 } 1205 1206 return false; 1207 } 974 1208 975 1209 /** -
branches/plugin/bbp-includes/bbp-functions.php
r2740 r2746 306 306 $bbp->errors->add( 'bbp_topic_forum_id', __( '<strong>ERROR</strong>: Forum ID is missing.', 'bbpress' ) ); 307 307 308 if ( bbp_is_forum_category( $forum_id ) ) 309 $bbp->errors->add( 'bbp_topic_forum_category', __( '<strong>ERROR</strong>: This forum is a category. No topics can be created in this forum!', 'bbpress' ) ); 310 311 if ( bbp_is_forum_closed( $forum_id ) && !current_user_can( 'edit_forum', $forum_id ) ) 312 $bbp->errors->add( 'bbp_topic_forum_closed', __( '<strong>ERROR</strong>: This forum has been closed to new topics!', 'bbpress' ) ); 313 314 if ( bbp_is_forum_private( $forum_id ) && !current_user_can( 'read_private_forums' ) ) 315 $bbp->errors->add( 'bbp_topic_forum_private', __( '<strong>ERROR</strong>: This forum is private and you do not have the capability to read or create new topics in this forum!', 'bbpress' ) ); 316 308 317 // Check for flood 309 318 if ( !bbp_check_for_flood( $anonymous_data, $topic_author ) ) … … 624 633 */ 625 634 function bbp_pre_get_posts ( $wp_query ) { 626 global $bbp ;635 global $bbp, $wp_version; 627 636 628 637 $bbp_user = get_query_var( 'bbp_user' ); … … 645 654 // Define new query variable 646 655 if ( !empty( $is_user_edit ) ) { 647 global $wp_version;648 649 656 // Only allow super admins on multisite to edit every user. 650 657 if ( ( is_multisite() && !current_user_can( 'manage_network_users' ) && $user_id != $current_user->ID && ! apply_filters( 'enable_edit_any_user_configuration', true ) ) || !current_user_can( 'edit_user', $user->ID ) ) -
branches/plugin/bbp-includes/bbp-general-template.php
r2734 r2746 236 236 237 237 /** 238 * Output a select box allowing to pick which forum/topic a new topic/reply 239 * belongs in. 240 * 241 * Can be used for any post type, but is mostly used for topics and forums. 242 * 243 * @since bbPress (r2744) 244 * 245 * @param mixed $args See {@link bbp_get_dropdown()} for arguments 246 */ 247 function bbp_dropdown( $args = '' ) { 248 echo bbp_get_dropdown( $args ); 249 } 250 /** 251 * Output a select box allowing to pick which forum/topic a new 252 * topic/reply belongs in. 253 * 254 * @since bbPress (r2744) 255 * 256 * @param mixed $args The function supports these args: 257 * - post_type: Post type, defaults to $bbp->forum_id (bbp_forum) 258 * - selected: Selected ID, to not have any value as selected, pass 259 * anything smaller than 0 (due to the nature of select 260 * box, the first value would of course be selected - 261 * though you can have that as none (pass 'show_none' arg)) 262 * - sort_column: Sort by? Defaults to 'menu_order, post_title' 263 * - child_of: Child of. Defaults to 0 264 * - post_status: Which all post_statuses to find in? Can be an array 265 * or CSV of publish, category, closed, private, spam, 266 * trash (based on post type) - if not set, these are 267 * automatically determined based on the post_type 268 * - posts_per_page: Retrieve all forums/topics. Defaults to -1 to get 269 * all posts 270 * - walker: Which walker to use? Defaults to 271 * {@link BBP_Walker_Dropdown} 272 * - select_id: ID of the select box. Defaults to 'bbp_forum_id' 273 * - tab: Tabindex value. False or integer 274 * - options_only: Show only <options>? No <select>? 275 * - show_none: False or something like __( '(No Forum)', 'bbpress' ), will have value="" 276 * - none_found: False or something like __( 'No forums to post to!', 'bbpress' ) 277 * - disable_categories: Disable forum categories? Defaults to true. Only for forums and when the category option is displayed. 278 * @return string 279 */ 280 function bbp_get_dropdown( $args = '' ) { 281 global $bbp; 282 283 $defaults = array ( 284 'post_type' => $bbp->forum_id, 285 'selected' => 0, 286 'sort_column' => 'post_title', 287 'child_of' => '0', 288 'post_status' => 'publish', 289 'numberposts' => -1, 290 'orderby' => 'menu_order', 291 'walker' => '', 292 293 // Output-related 294 'select_id' => 'bbp_forum_id', 295 'tab' => false, 296 'options_only' => false, 297 'show_none' => false, 298 'none_found' => false, 299 'disable_categories' => true 300 ); 301 302 $r = wp_parse_args( $args, $defaults ); 303 304 if ( empty( $r['walker'] ) ) { 305 $r['walker'] = new BBP_Walker_Dropdown(); 306 $r['walker']->tree_type = $r['post_type']; 307 } 308 309 // Determine a selected value 310 if ( empty( $r['selected'] ) ) { 311 312 // We're getting forums 313 if ( $r['post_type'] == $bbp->forum_id ) { 314 $r['selected'] = bbp_get_forum_id(); 315 316 // We're getting topics 317 } elseif ( $r['post_type'] == $bbp->topic_id ) { 318 $r['selected'] = bbp_get_topic_id(); 319 } 320 } 321 322 // Force 0 323 if ( is_numeric( $r['selected'] ) && $r['selected'] < 0 ) 324 $r['selected'] = 0; 325 326 // Don't show private forums to normal users 327 if ( !current_user_can( 'edit_others_forums' ) && empty( $r['meta_key'] ) && empty( $r['meta_value'] ) && empty( $r['meta_compare'] ) ) { 328 $r['meta_key'] = '_bbp_forum_visibility'; 329 $r['meta_value'] = 'public'; 330 $r['meta_compare'] = '=='; 331 } 332 333 extract( $r ); 334 335 // Unset the args not needed for WP_Query to avoid any possible conflicts. 336 // Note: walker and disable_categories are not unset 337 unset( $r['select_id'], $r['tab'], $r['options_only'], $r['show_none'], $r['none_found'] ); 338 339 // Setup variables 340 $name = esc_attr( $select_id ); 341 $select_id = $name; 342 $tab = (int) $tab; 343 $retval = ''; 344 345 // @todo - write a better get_ function 346 if ( $r['post_type'] == $bbp->forum_id ) 347 $posts = get_pages( $r ); 348 elseif ( $r['post_type'] == $bbp->topic_id ) 349 $posts = get_posts( $r ); 350 351 // Make a drop down if we found posts 352 if ( !empty( $posts ) ) { 353 if ( empty( $options_only ) ) { 354 $tab = !empty( $tab ) ? ' tabindex="' . $tab . '"' : ''; 355 $retval .= '<select name="' . $name . '" id="' . $select_id . '"' . $tab . '>' . "\n"; 356 } 357 358 $retval .= !empty( $show_none ) ? "\t<option value=\"\" class=\"level-0\">" . $show_none . '</option>' : ''; 359 $retval .= walk_page_dropdown_tree( $posts, 0, $r ); 360 361 if ( empty( $options_only ) ) 362 $retval .= '</select>'; 363 364 // Display feedback 365 } else { 366 // Long short hand 367 $retval .= !empty( $none_found ) ? $none_found : $post_type == $bbp->topic_id ? __( 'No topics to post to!', 'bbpress' ) : $post_type == $bbp->forum_id ? __( 'No forums to post to!', 'bbpress' ) : __( 'No posts found!', 'bbpress' ); 368 } 369 370 return apply_filters( 'bbp_get_dropdown', $retval, $args ); 371 } 372 373 /** 238 374 * bbp_new_topic_form_fields () 239 375 * … … 288 424 <?php wp_nonce_field( 'update-user_' . bbp_get_displayed_user_id() ); 289 425 } 290 291 /**292 * bbp_forum_dropdown ()293 *294 * Output a select box allowing to pick which forum a new topic belongs in.295 *296 * @param array $args297 */298 function bbp_forum_dropdown ( $args = '' ) {299 echo bbp_get_forum_dropdown( $args );300 }301 /**302 * bbp_get_forum_dropdown ()303 *304 * Return a select box allowing to pick which forum a new topic belongs in.305 *306 * @global object $bbp307 * @param array $args308 * @return string309 */310 function bbp_get_forum_dropdown ( $args = '' ) {311 global $bbp;312 313 $defaults = array (314 'post_type' => $bbp->forum_id,315 'selected' => bbp_get_forum_id(),316 'sort_column' => 'menu_order, post_title',317 'child_of' => '0',318 );319 320 $r = wp_parse_args( $args, $defaults );321 extract( $r );322 323 if ( $forums = get_posts( $r ) ) {324 $output = '<select name="bbp_forum_id" id="bbp_forum_id">';325 $output .= walk_page_dropdown_tree( $forums, 0, $r );326 $output .= '</select>';327 } else {328 $output = __( 'No forums to post to!', 'bbpress' );329 }330 331 return apply_filters( 'bbp_get_forums_dropdown', $output );332 }333 426 334 427 /** END Form Functions ********************************************************/ -
branches/plugin/bbp-includes/bbp-reply-template.php
r2745 r2746 822 822 823 823 if ( !bbp_is_topic() && !bbp_is_reply() ) 824 return '  ';824 return ' '; 825 825 826 826 $defaults = array ( … … 839 839 840 840 if ( !current_user_can( 'edit_reply', $r['id'] ) ) 841 return '  ';841 return ' '; 842 842 843 843 if ( !current_user_can( 'delete_reply', $r['id'] ) ) -
branches/plugin/bbp-includes/bbp-topic-template.php
r2745 r2746 311 311 * @since bbPress (r2727) 312 312 * 313 * @uses bbp_get_topic_id() 314 * @uses bbp_get_topic_status() 313 * @uses bbp_is_topic_closed() 315 314 * 316 315 * @param int $topic_id optional … … 318 317 */ 319 318 function bbp_is_topic_open ( $topic_id = 0 ) { 320 global $bbp; 321 322 $topic_status = bbp_get_topic_status( bbp_get_topic_id( $topic_id ) ); 323 return $bbp->closed_status_id != $topic_status; 324 } 319 return !bbp_is_topic_closed( $topic_id ); 320 } 321 322 /** 323 * bbp_is_topic_closed () 324 * 325 * Is the topic closed to new replies? 326 * 327 * @package bbPress 328 * @subpackage Template Tags 329 * @since bbPress (r2744) 330 * 331 * @uses bbp_get_topic_status() 332 * 333 * @param int $topic_id optional 334 * @return bool True if closed, false if not. 335 */ 336 function bbp_is_topic_closed ( $topic_id = 0 ) { 337 global $bbp; 338 339 if ( $bbp->closed_status_id == bbp_get_topic_status( $topic_id ) ) 340 return true; 341 342 return false; 343 } 325 344 326 345 /** … … 1195 1214 1196 1215 if ( !bbp_is_topic() ) 1197 return '  ';1216 return ' '; 1198 1217 1199 1218 $defaults = array ( … … 1215 1234 1216 1235 if ( !current_user_can( 'edit_topic', $r['id'] ) ) 1217 return '  ';1236 return ' '; 1218 1237 1219 1238 // Check caps for trashing the topic … … 1317 1336 'link_after' => '', 1318 1337 'sep' => ' | ', 1319 'trash_text' => __( 'Trash', 1320 'restore_text' => __( 'Restore', 1321 'delete_text' => __( 'Delete Permanentatly','bbpress' )1338 'trash_text' => __( 'Trash', 'bbpress' ), 1339 'restore_text' => __( 'Restore', 'bbpress' ), 1340 'delete_text' => __( 'Delete', 'bbpress' ) 1322 1341 ); 1323 1342 $r = wp_parse_args( $args, $defaults ); … … 1806 1825 do_action( 'bbp_close_topic', $topic_id ); 1807 1826 1808 add_post_meta( $topic_id, '_bbp_ close_meta_status', $topic['post_status'] );1827 add_post_meta( $topic_id, '_bbp_topic_status', $topic['post_status'] ); 1809 1828 1810 1829 $topic['post_status'] = $bbp->closed_status_id; … … 1837 1856 do_action( 'bbp_open_topic', $topic_id ); 1838 1857 1839 $topic_status = get_post_meta( $topic_id, '_bbp_ close_meta_status', true );1858 $topic_status = get_post_meta( $topic_id, '_bbp_topic_status', true ); 1840 1859 $topic['post_status'] = $topic_status; 1841 1860 1842 delete_post_meta( $topic_id, '_bbp_ close_meta_status' );1861 delete_post_meta( $topic_id, '_bbp_topic_status' ); 1843 1862 1844 1863 wp_insert_post( $topic ); -
branches/plugin/bbp-themes/bbp-twentyten/css/bbpress.css
r2740 r2746 64 64 } 65 65 66 .bbp-forum-topic-count, .bbp-forum- topic-replies,66 .bbp-forum-topic-count, .bbp-forum-reply-count, 67 67 .bbp-topic-reply-count, .bbp-topic-voice-count, .bbp-topic-action { 68 68 width: 10%; … … 187 187 .bbp-topic-form, .bbp-reply-form { 188 188 clear: left; 189 } 190 191 p#bbp_topic_submit_container { 192 float: right; 189 193 } 190 194 … … 262 266 border-color: #e6db55; 263 267 color: #000; 268 clear: both; 264 269 } 265 270 div.bbp-template-notice.important { -
branches/plugin/bbp-themes/bbp-twentyten/form-bbp_reply.php
r2735 r2746 35 35 <p> 36 36 <label for="bbp_topic_tags"><?php _e( 'Tags:', 'bbpress' ); ?></label><br /> 37 <input id="bbp_topic_tags" type="text" value="" tabindex="10" size="40" name="bbp_topic_tags" id="post_tags"/>37 <input id="bbp_topic_tags" type="text" value="" tabindex="10" size="40" name="bbp_topic_tags" /> 38 38 </p> 39 39 … … 47 47 <?php endif; ?> 48 48 49 <p align="right">49 <p id="bbp_topic_submit_container"> 50 50 <button type="submit" tabindex="14" id="bbp_reply_submit" name="bbp_reply_submit"><?php _e( 'Submit', 'bbpress' ); ?></button> 51 51 </p> -
branches/plugin/bbp-themes/bbp-twentyten/form-bbp_topic.php
r2685 r2746 2 2 <?php if ( current_user_can( 'publish_topics' ) || bbp_allow_anonymous() ) : ?> 3 3 4 <div id="new-topic-<?php bbp_topic_id(); ?>" class="bbp-topic-form"> 5 <form id="new_post" name="new_post" method="post" action=""> 6 <fieldset> 7 <legend><?php bbp_is_forum() ? printf( __( 'Create new topic in: “%s”', 'bbpress' ), bbp_get_forum_title() ) : _e( 'Create new topic', 'bbpress' ); ?></legend> 4 <?php if ( !bbp_is_forum_category() && ( !bbp_is_forum_closed() || current_user_can( 'edit_forum', bbp_get_topic_forum_id() ) ) ) : ?> 8 5 9 <div class="alignleft"> 6 <div id="new-topic-<?php bbp_topic_id(); ?>" class="bbp-topic-form"> 7 <form id="new_post" name="new_post" method="post" action=""> 8 <fieldset> 9 <legend><?php bbp_is_forum() ? printf( __( 'Create new topic in: “%s”', 'bbpress' ), bbp_get_forum_title() ) : _e( 'Create new topic', 'bbpress' ); ?></legend> 10 10 11 <?php bbp_current_user_avatar( 80 );?>11 <?php if ( bbp_is_forum_closed() ) : ?> 12 12 13 </div> 14 15 <div class="alignleft"> 16 17 <?php get_template_part( 'form', 'bbp_anonymous' ); ?> 18 19 <p> 20 <label for="bbp_topic_title"><?php _e( 'Title:', 'bbpress' ); ?></label><br /> 21 <input type="text" id="bbp_topic_title" value="" tabindex="8" size="40" name="bbp_topic_title" /> 22 </p> 23 24 <p> 25 <label for="bbp_topic_content"><?php _e( 'Topic:', 'bbpress' ); ?></label><br /> 26 <textarea id="bbp_topic_content" tabindex="10" name="bbp_topic_content" cols="52" rows="6"></textarea> 27 </p> 28 29 <p> 30 <label for="bbp_topic_tags"><?php _e( 'Tags:', 'bbpress' ); ?></label><br /> 31 <input type="text" value="" tabindex="12" size="40" name="bbp_topic_tags" id="post_tags" /> 32 </p> 33 34 <?php if ( !bbp_is_forum() ) : ?> 35 36 <p> 37 <label for="bbp_forum_id"><?php _e( 'Forum:', 'bbpress' ); ?></label><br /> 38 <?php bbp_forum_dropdown(); ?> 39 </p> 13 <div class="bbp-template-notice"> 14 <p><?php _e( 'This forum is marked as closed to new topics, however your posting capabilities still allow you to do so.', 'bbpress' ); ?></p> 15 </div> 40 16 41 17 <?php endif; ?> 42 18 43 <?php if ( bbp_is_subscriptions_active() && !bbp_is_anonymous() ) : ?> 19 <div class="alignleft"> 20 21 <?php bbp_current_user_avatar( 80 ); ?> 22 23 </div> 24 25 <div class="alignleft"> 26 27 <?php get_template_part( 'form', 'bbp_anonymous' ); ?> 44 28 45 29 <p> 46 < input name="bbp_topic_subscription" id="bbp_topic_subscription" type="checkbox" value="bbp_subscribe" tabindex="16"/>47 < label for="bbp_topic_subscription"><?php _e( 'Notify me of follow-up replies via email', 'bbpress' ); ?></label>30 <label for="bbp_topic_title"><?php _e( 'Title:', 'bbpress' ); ?></label><br /> 31 <input type="text" id="bbp_topic_title" value="" tabindex="8" size="40" name="bbp_topic_title" /> 48 32 </p> 49 33 50 <?php endif; ?> 34 <p> 35 <label for="bbp_topic_content"><?php _e( 'Topic:', 'bbpress' ); ?></label><br /> 36 <textarea id="bbp_topic_content" tabindex="10" name="bbp_topic_content" cols="52" rows="6"></textarea> 37 </p> 51 38 52 <p align="right">53 <button type="submit" tabindex="18" id="bbp_topic_submit" name="bbp_topic_submit"><?php _e( 'Submit', 'bbpress' ); ?></button>54 </p>55 </div>39 <p> 40 <label for="bbp_topic_tags"><?php _e( 'Tags:', 'bbpress' ); ?></label><br /> 41 <input type="text" value="" tabindex="12" size="40" name="bbp_topic_tags" id="bbp_topic_tags" /> 42 </p> 56 43 57 <?php bbp_new_topic_form_fields();?>44 <?php if ( !bbp_is_forum() ) : ?> 58 45 59 </fieldset> 60 </form> 61 </div> 46 <p> 47 <label for="bbp_forum_id"><?php _e( 'Forum:', 'bbpress' ); ?></label><br /> 48 <?php bbp_dropdown(); ?> 49 </p> 50 51 <?php endif; ?> 52 53 <?php if ( bbp_is_subscriptions_active() && !bbp_is_anonymous() ) : ?> 54 55 <p> 56 <input name="bbp_topic_subscription" id="bbp_topic_subscription" type="checkbox" value="bbp_subscribe" tabindex="16" /> 57 <label for="bbp_topic_subscription"><?php _e( 'Notify me of follow-up replies via email', 'bbpress' ); ?></label> 58 </p> 59 60 <?php endif; ?> 61 62 <p id="bbp_topic_submit_container"> 63 <button type="submit" tabindex="18" id="bbp_topic_submit" name="bbp_topic_submit"><?php _e( 'Submit', 'bbpress' ); ?></button> 64 </p> 65 </div> 66 67 <?php bbp_new_topic_form_fields(); ?> 68 69 </fieldset> 70 </form> 71 </div> 72 73 <?php elseif ( bbp_is_forum_closed() ) : ?> 74 75 <div class="bbp-template-notice"> 76 <p><?php _e( 'This forum is closed to new topics.', 'bbpress' ); ?></p> 77 </div> 78 79 <?php endif; ?> 62 80 63 81 <?php else : ?> -
branches/plugin/bbp-themes/bbp-twentyten/loop-bbp_forums.php
r2708 r2746 41 41 <td class="bbp-forum-topic-count"><?php bbp_forum_topic_count(); ?></td> 42 42 43 <td class="bbp-forum- topic-replies"><?php bbp_forum_reply_count(); ?></td>43 <td class="bbp-forum-reply-count"><?php bbp_forum_reply_count(); ?></td> 44 44 45 45 <td class="bbp-forum-freshness"><?php bbp_forum_freshness_link(); ?></td> -
branches/plugin/bbp-themes/bbp-twentyten/loop-bbp_topics.php
r2720 r2746 23 23 24 24 <tfoot> 25 <tr><td colspan="<?php echo ( bbp_is_user_home() && ( bbp_is_favorites() || bbp_is_subscriptions() ) ) ? '5' : '4'; ?>">  </td></tr>25 <tr><td colspan="<?php echo ( bbp_is_user_home() && ( bbp_is_favorites() || bbp_is_subscriptions() ) ) ? '5' : '4'; ?>"> </td></tr> 26 26 </tfoot> 27 27 -
branches/plugin/bbp-themes/bbp-twentyten/single-bbp_forum.php
r2734 r2746 17 17 <?php while ( have_posts() ) : the_post(); ?> 18 18 19 <div id="forum-<?php bbp_forum_id(); ?>" class="bbp-forum-info"> 20 <h1 class="entry-title"><?php bbp_title_breadcrumb(); ?></h1> 21 <div class="entry-content"> 19 <?php if ( !bbp_is_forum_private() || current_user_can( 'edit_others_forums' ) ) : ?> 22 20 23 <?php the_content(); ?> 21 <div id="forum-<?php bbp_forum_id(); ?>" class="bbp-forum-info"> 22 <h1 class="entry-title"><?php bbp_title_breadcrumb(); ?></h1> 23 <div class="entry-content"> 24 24 25 <?php get_template_part( 'loop', 'bbp_forums'); ?>25 <?php the_content(); ?> 26 26 27 <?php get_template_part( 'loop', 'bbp_topics' ); ?>27 <?php get_template_part( 'loop', 'bbp_forums' ); ?> 28 28 29 <?php get_template_part( 'form', 'bbp_topic' );?>29 <?php if ( !bbp_is_forum_category() ) : ?> 30 30 31 </div> 32 </div><!-- #forum-<?php bbp_forum_id(); ?> --> 31 <?php get_template_part( 'loop', 'bbp_topics' ); ?> 32 33 <?php get_template_part( 'form', 'bbp_topic' ); ?> 34 35 <?php endif; ?> 36 37 </div> 38 </div><!-- #forum-<?php bbp_forum_id(); ?> --> 39 40 <?php else : ?> 41 42 <div id="forum-private" class="bbp-forum-info"> 43 <h1 class="entry-title"><?php _e( 'Private Forum!', 'bbpress' ); ?></h1> 44 <div class="entry-content"> 45 46 <div class="bbp-template-notice"> 47 <p><?php _e( 'This forum is marked as private, and you do not have permission to view it.', 'bbpress' ); ?></p> 48 </div> 49 50 </div> 51 </div><!-- #forum-private --> 52 53 <?php endif; ?> 33 54 34 55 <?php endwhile; ?> -
branches/plugin/bbp-themes/bbp-twentyten/single-bbp_topic.php
r2740 r2746 20 20 <h1 class="entry-title"><?php bbp_title_breadcrumb(); ?></h1> 21 21 <div class="entry-content"> 22 23 <p class="topic_counts"> 24 <span class="topic_replies"><?php printf( __( '(%s)', 'bbpress' ), bbp_get_topic_replies_link() ); ?></span> 25 <span class="topic_voices"><?php printf( _n( '(%s voice)', '(%s voices)', bbp_get_topic_voice_count(), 'bbpress' ), bbp_get_topic_voice_count() ); ?></span> 26 </p> 22 27 23 28 <?php bbp_topic_tag_list(); ?> -
branches/plugin/bbpress.php
r2744 r2746 29 29 class bbPress { 30 30 31 // Content type and taxonomy identifiers31 // Post type 32 32 var $forum_id; 33 33 var $topic_id; 34 34 var $reply_id; 35 36 // Post status identifiers 37 var $closed_status_id; 38 var $spam_status_id; 39 var $trash_status_id; 40 41 // Taxonomy identifier 35 42 var $topic_tag_id; 36 var $spam_status_id;37 var $closed_status_id;38 var $trash_status_id;39 43 40 44 // Slugs 45 var $user_slug; 41 46 var $forum_slug; 42 47 var $topic_slug; 43 48 var $reply_slug; 44 49 var $topic_tag_slug; 45 var $user_slug;46 50 47 51 // Absolute Paths … … 93 97 94 98 // bbPress root directory 95 $this->file = __FILE__;96 $this->plugin_dir = plugin_dir_path( $this->file );97 $this->plugin_url = plugin_dir_url ( $this->file );99 $this->file = __FILE__; 100 $this->plugin_dir = plugin_dir_path( $this->file ); 101 $this->plugin_url = plugin_dir_url ( $this->file ); 98 102 99 103 // Images 100 $this->images_url = $this->plugin_url . 'bbp-images';104 $this->images_url = $this->plugin_url . 'bbp-images'; 101 105 102 106 // Themes 103 $this->themes_dir = WP_PLUGIN_DIR . '/' . basename( dirname( __FILE__ ) ) . '/bbp-themes';104 $this->themes_url = $this->plugin_url . 'bbp-themes';107 $this->themes_dir = WP_PLUGIN_DIR . '/' . basename( dirname( __FILE__ ) ) . '/bbp-themes'; 108 $this->themes_url = $this->plugin_url . 'bbp-themes'; 105 109 106 110 /** Identifiers ***********************************************/ 107 111 108 112 // Post type identifiers 109 $this->forum_id = apply_filters( 'bbp_forum_post_type', 'bbp_forum' );110 $this->topic_id = apply_filters( 'bbp_topic_post_type', 'bbp_topic' );111 $this->reply_id = apply_filters( 'bbp_reply_post_type', 'bbp_reply' );112 $this->topic_tag_id = apply_filters( 'bbp_topic_tag_id', 'bbp_topic_tag' );113 114 // Post status identifiers115 $this->spam_status_id = apply_filters( 'bbp_spam_post_status', 'spam');116 $this->closed_status_id = apply_filters( 'bbp_closed_post_status', 'closed');117 $this->trash_status_id = 'trash';113 $this->forum_id = apply_filters( 'bbp_forum_post_type', 'bbp_forum' ); 114 $this->topic_id = apply_filters( 'bbp_topic_post_type', 'bbp_topic' ); 115 $this->reply_id = apply_filters( 'bbp_reply_post_type', 'bbp_reply' ); 116 $this->topic_tag_id = apply_filters( 'bbp_topic_tag_id', 'bbp_topic_tag' ); 117 118 // Status identifiers 119 $this->spam_status_id = apply_filters( 'bbp_spam_post_status', 'spam' ); 120 $this->closed_status_id = apply_filters( 'bbp_closed_post_status', 'closed' ); 121 $this->trash_status_id = 'trash'; 118 122 119 123 /** Slugs *****************************************************/ 120 124 121 125 // Root forum slug 122 $this->root_slug = apply_filters( 'bbp_root_slug', get_option( '_bbp_root_slug', 'forums' ) );126 $this->root_slug = apply_filters( 'bbp_root_slug', get_option( '_bbp_root_slug', 'forums' ) ); 123 127 124 128 // Should we include the root slug in front of component slugs … … 126 130 127 131 // Component slugs 128 $this->user_slug = apply_filters( 'bbp_user_slug', get_option( '_bbp_user_slug', $prefix . 'user' ) );129 $this->forum_slug = apply_filters( 'bbp_forum_slug', get_option( '_bbp_forum_slug', $prefix . 'forum' ) );130 $this->topic_slug = apply_filters( 'bbp_topic_slug', get_option( '_bbp_topic_slug', $prefix . 'topic' ) );131 $this->reply_slug = apply_filters( 'bbp_reply_slug', get_option( '_bbp_reply_slug', $prefix . 'reply' ) );132 $this->topic_tag_slug = apply_filters( 'bbp_topic_tag_slug', get_option( '_bbp_topic_tag_slug', $prefix . 'tag' ) );132 $this->user_slug = apply_filters( 'bbp_user_slug', get_option( '_bbp_user_slug', $prefix . 'user' ) ); 133 $this->forum_slug = apply_filters( 'bbp_forum_slug', get_option( '_bbp_forum_slug', $prefix . 'forum' ) ); 134 $this->topic_slug = apply_filters( 'bbp_topic_slug', get_option( '_bbp_topic_slug', $prefix . 'topic' ) ); 135 $this->reply_slug = apply_filters( 'bbp_reply_slug', get_option( '_bbp_reply_slug', $prefix . 'reply' ) ); 136 $this->topic_tag_slug = apply_filters( 'bbp_topic_tag_slug', get_option( '_bbp_topic_tag_slug', $prefix . 'tag' ) ); 133 137 134 138 /** Misc ******************************************************/ … … 279 283 'editor', 280 284 'thumbnail', 281 'excerpt', 282 'page-attributes' 285 'excerpt' 283 286 ); 284 287 … … 415 418 */ 416 419 function register_post_statuses () { 417 418 // Closed 419 $status = apply_filters( 'bbp_register_closed_post_status', array ( 420 'label' => _x( 'Closed', 'post', 'bbpress' ), 421 'label_count' => _nx_noop( 'Closed <span class="count">(%s)</span>', 'Closed <span class="count">(%s)</span>', 'bbpress' ), 422 'public' => true, 423 'show_in_admin_all' => true 424 ) ); 425 register_post_status ( $this->closed_status_id, $status ); 426 427 // Spam 428 $status = apply_filters( 'bbp_register_spam_post_status', array ( 429 'label' => _x( 'Spam', 'post', 'bbpress' ), 430 'label_count' => _nx_noop( 'Spam <span class="count">(%s)</span>', 'Spam <span class="count">(%s)</span>', 'bbpress' ), 431 'protected' => true, 432 'exclude_from_search' => true, 433 'show_in_admin_status_list' => true, 434 'show_in_admin_all_list' => false 435 ) ); 436 register_post_status ( $this->spam_status_id, $status ); 437 420 global $wp_post_statuses; 421 422 // Closed (for forums and topics) 423 register_post_status ( 424 $this->closed_status_id, 425 apply_filters( 'bbp_register_closed_post_status', 426 array( 427 'label' => _x( 'Closed', 'post', 'bbpress' ), 428 'label_count' => _nx_noop( 'Closed <span class="count">(%s)</span>', 'Closed <span class="count">(%s)</span>', 'bbpress' ), 429 'public' => true, 430 'show_in_admin_all' => true 431 ) 432 ) 433 ); 434 435 // Spam (for topics and replies) 436 register_post_status ( 437 $this->spam_status_id, 438 apply_filters( 'bbp_register_spam_post_status', 439 array( 440 'label' => _x( 'Spam', 'post', 'bbpress' ), 441 'label_count' => _nx_noop( 'Spam <span class="count">(%s)</span>', 'Spam <span class="count">(%s)</span>', 'bbpress' ), 442 'protected' => true, 443 'exclude_from_search' => true, 444 'show_in_admin_status_list' => true, 445 'show_in_admin_all_list' => false 446 ) 447 ) 448 ); 438 449 439 450 // Trash 440 if ( current_user_can( 'view_trash' ) ) { 441 /** 442 * We need to remove the internal arg and change that to 443 * protected so that the users with 'view_trash' cap can view 444 * single trashed topics/replies in the front-end as wp_query 445 * doesn't allow any hack for the trashed topics to be viewed. 446 */ 447 448 $status = apply_filters( 'bbp_register_trash_post_status', array ( 449 'label' => _x( 'Trash', 'post', 'bbpress' ), 450 'label_count' => _nx_noop( 'Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', 'bbpress' ), 451 //'internal' => true, // Changed to protected 452 'protected' => true, 453 '_builtin' => true, // Internal use only. 454 'exclude_from_search' => true, 455 'show_in_admin_status_list' => true, 456 'show_in_admin_all_list' => false 457 ) ); 458 register_post_status( $this->trash_status_id, $status ); 451 452 /* We need to remove the internal arg and change that to 453 * protected so that the users with 'view_trash' cap can view 454 * single trashed topics/replies in the front-end as wp_query 455 * doesn't allow any hack for the trashed topics to be viewed. 456 */ 457 if ( !empty( $wp_post_statuses['trash'] ) && current_user_can( 'view_trash' ) ) { 458 $wp_post_statuses['trash']->internal = false; /* changed to protected */ 459 $wp_post_statuses['trash']->protected = true; 459 460 } 461 462 // Private 463 464 /* Similarly, we need to remove the internal arg and change that 465 * to protected so that the users with 'read_private_forums' cap 466 * can view private forums in the front-end. 467 */ 468 if ( !empty( $wp_post_statuses['private'] ) && current_user_can( 'read_private_forums' ) ) { 469 $wp_post_statuses['private']->internal = false; /* changed to protected */ 470 $wp_post_statuses['private']->protected = true; 471 } 472 460 473 } 461 474
Note: See TracChangeset
for help on using the changeset viewer.