[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 3 function bb_get_admin_header() 4 { 5 do_action( 'bb_admin-header.php' ); 6 include( 'admin-header.php' ); 7 do_action( 'bb_get_admin_header' ); 8 } 9 10 function bb_get_admin_footer() 11 { 12 do_action( 'bb_admin-footer.php' ); 13 include( 'admin-footer.php' ); 14 } 15 16 function bb_admin_notice( $message, $class = false ) 17 { 18 if ( is_string( $message ) ) { 19 $message = '<p>' . $message . '</p>'; 20 $class = $class ? $class : 'updated'; 21 } elseif ( is_wp_error( $message ) ) { 22 $errors = $message->get_error_messages(); 23 switch ( count( $errors ) ) { 24 case 0: 25 return false; 26 break; 27 case 1: 28 $message = '<p>' . $errors[0] . '</p>'; 29 break; 30 default: 31 $message = '<ul>' . "\n\t" . '<li>' . join( '</li>' . "\n\t" . '<li>', $errors ) . '</li>' . "\n" . '</ul>'; 32 break; 33 } 34 $class = $class ? $class : 'error'; 35 } else { 36 return false; 37 } 38 39 $message = '<div id="message" class="' . esc_attr( $class ) . '">' . $message . '</div>'; 40 $message = str_replace( "'", "\'", $message ); 41 $lambda = create_function( '', "echo '$message';" ); 42 add_action( 'bb_admin_notices', $lambda ); 43 return $lambda; 44 } 45 46 /* Menu */ 47 48 function bb_admin_menu_generator() 49 { 50 global $bb_menu, $bb_submenu; 51 $bb_menu = array(); 52 $bb_submenu = array(); 53 54 // Dashboard menu items < 50 55 $bb_menu[0] = array( __( 'Dashboard' ), 'moderate', 'index.php', '', 'bb-menu-dashboard' ); 56 $bb_submenu['index.php'][5] = array( __( 'Dashboard' ), 'moderate', 'index.php' ); 57 58 // 50 < Plugin added menu items < 100 59 60 $bb_menu[100] = array( '', 'read', 'separator' ); 61 62 // 100 < Plugin added menu items < 150 63 64 // 150 < First menu items < 200 65 $bb_menu[150] = array( __( 'Forums' ), 'manage_forums', 'forums.php', '', 'bb-menu-forums' ); 66 $bb_submenu['forums.php'][5] = array( __( 'Forums' ), 'manage_forums', 'forums.php' ); 67 $bb_menu[155] = array( __( 'Topics' ), 'moderate', 'topics.php', '', 'bb-menu-topics' ); 68 $bb_submenu['topics.php'][5] = array( __( 'Topics' ), 'moderate', 'topics.php' ); 69 $bb_menu[160] = array( __( 'Posts' ), 'moderate', 'posts.php', '', 'bb-menu-posts' ); 70 $bb_submenu['posts.php'][5] = array( __( 'Posts' ), 'moderate', 'posts.php' ); 71 72 // 200 < Plugin added menu items < 250 73 74 $bb_menu[250] = array( '', 'read', 'separator' ); 75 76 // 250 < Plugin added menu items < 300 77 78 // 300 < Second menu items < 350 79 $bb_menu[300] = array( __( 'Appearance' ), 'manage_themes', 'themes.php', '', 'bb-menu-appearance' ); 80 $bb_submenu['themes.php'][5] = array(__('Themes'), 'manage_themes', 'themes.php'); 81 $bb_menu[305] = array( __( 'Plugins' ), 'use_keys', 'plugins.php', '', 'bb-menu-plugins' ); 82 $bb_submenu['plugins.php'][5] = array( __( 'Installed' ), 'manage_plugins', 'plugins.php' ); 83 $bb_menu[310] = array( __( 'Users' ), 'moderate', 'users.php', '', 'bb-menu-users' ); 84 $bb_submenu['users.php'][5] = array( __( 'Users' ), 'moderate', 'users.php' ); 85 $bb_submenu['users.php'][10] = array( __( 'Add New' ), 'manage_options', 'user-add-new.php' ); 86 $bb_menu[315] = array( __( 'Tools' ), 'recount', 'tools-recount.php', '', 'bb-menu-tools' ); 87 $bb_submenu['tools-recount.php'][5] = array( __( 'Re-count' ), 'recount', 'tools-recount.php' ); 88 $bb_menu[320] = array( __( 'Settings' ), 'manage_options', 'options-general.php', '', 'bb-menu-settings' ); 89 $bb_submenu['options-general.php'][5] = array( __( 'General' ), 'manage_options', 'options-general.php' ); 90 //$bb_submenu['options-general.php'][10] = array( __( 'Date and Time' ), 'manage_options', 'options-time.php' ); 91 $bb_submenu['options-general.php'][15] = array( __( 'Writing' ), 'manage_options', 'options-writing.php' ); 92 $bb_submenu['options-general.php'][20] = array( __( 'Reading' ), 'manage_options', 'options-reading.php' ); 93 $bb_submenu['options-general.php'][25] = array( __( 'Discussion' ), 'manage_options', 'options-discussion.php' ); 94 $bb_submenu['options-general.php'][30] = array( __( 'Permalinks' ), 'manage_options', 'options-permalinks.php' ); 95 $bb_submenu['options-general.php'][35] = array( __( 'WordPress Integration' ), 'manage_options', 'options-wordpress.php' ); 96 97 // 350 < Plugin added menu items 98 99 do_action( 'bb_admin_menu_generator' ); 100 ksort( $bb_menu ); 101 102 $last_key = false; 103 foreach ( $bb_menu as $key => $m ) { 104 if ( $last_key === false || $bb_menu[$last_key][2] === 'separator' ) { 105 $bb_menu[$key][3] .= ' bb-menu-first'; 106 } 107 if ( $bb_menu[$key][2] === 'separator' ) { 108 $bb_menu[$last_key][3] .= ' bb-menu-last'; 109 } 110 $last_key = $key; 111 if ( isset( $bb_submenu[$m[2]] ) ) { 112 ksort( $bb_submenu[$m[2]] ); 113 } 114 } 115 $bb_menu[$last_key][3] .= ' bb-menu-last'; 116 } 117 118 function bb_admin_add_menu( $display_name, $capability, $file_name, $menu_position = false, $class = '', $id = '' ) 119 { 120 global $bb_menu; 121 global $bb_registered_plugin_callbacks; 122 if ( empty( $bb_registered_plugin_callbacks ) ) { 123 $bb_registered_plugin_callbacks = array(); 124 } 125 126 if ( $display_name && $capability && $file_name ) { 127 // Get an array of the keys 128 $menu_keys = array_keys( $bb_menu ); 129 130 if ( $menu_position ) { 131 if ( is_numeric( $menu_position ) ) { 132 if ( !isset( $bb_menu[$menu_position] ) ) { 133 $plugin_menu_next = $menu_position; 134 } else { 135 return bb_admin_add_menu( $display_name, $capability, $file_name, ( $menu_position + 1 ), $class, $id ); 136 } 137 } else { 138 // Set the bounds for different menu groups (main or side) 139 switch ( $menu_position ) { 140 case 'dash': 141 $lower = 50; 142 $upper = 100; 143 break; 144 case 'main': 145 $lower = 200; 146 $upper = 250; 147 break; 148 default: 149 $lower = 350; 150 $upper = 500; 151 break; 152 } 153 154 // Get an array of all plugin added keys 155 $plugin_menu_keys = array_filter( $menu_keys, create_function( '$v', 'if ($v >= ' . $lower . ' && $v < ' . $upper . ') { return $v; }' ) ); 156 157 // If there is an array of keys 158 if ( is_array( $plugin_menu_keys ) && count( $plugin_menu_keys ) ) { 159 // Get the highest key value and add one 160 $plugin_menu_next = max( $plugin_menu_keys ) + 1; 161 } else { 162 // It's the first one 163 $plugin_menu_next = $lower; 164 } 165 } 166 } else { 167 $plugin_menu_next = max( array_keys( $bb_menu ) ) + 1; 168 $bb_menu[$plugin_menu_next] = array( '', 'read', 'separator' ); 169 $plugin_menu_next++; 170 } 171 172 if ( strpos( $file_name, '.php' ) === false ) { 173 $bb_registered_plugin_callbacks[] = $file_name; 174 } 175 176 // Add the menu item at the given key 177 $bb_menu[$plugin_menu_next] = array( $display_name, $capability, $file_name, $class, $id ); 178 179 ksort( $bb_menu ); 180 181 return $plugin_menu_next; 182 } 183 184 return false; 185 } 186 187 function bb_admin_add_submenu( $display_name, $capability, $file_name, $parent = 'plugins.php' ) 188 { 189 global $bb_submenu; 190 global $bb_registered_plugin_callbacks; 191 if ( empty( $bb_registered_plugin_callbacks ) ) { 192 $bb_registered_plugin_callbacks = array(); 193 } 194 195 if ( $display_name && $capability && $file_name ) { 196 if ( strpos( $file_name, '.php' ) === false ) { 197 $bb_registered_plugin_callbacks[] = $file_name; 198 } 199 $bb_submenu[$parent][] = array( $display_name, $capability, $file_name ); 200 ksort( $bb_submenu ); 201 } 202 } 203 204 function bb_get_current_admin_menu() 205 { 206 global $bb_menu, $bb_submenu, $bb_admin_page, $bb_current_menu, $bb_current_submenu; 207 foreach ( $bb_submenu as $m => $b ) { 208 foreach ( $b as $s ) { 209 if ( $s[2] == $bb_admin_page ) { 210 $bb_current_submenu = $s; 211 $bb_current_menu = $m; 212 break; 213 } 214 } 215 } 216 if ( !isset($bb_current_menu) ) { 217 $bb_current_menu = $bb_menu[0]; 218 $bb_current_submenu = $bb_submenu['index.php'][5]; 219 } else { 220 foreach ( $bb_menu as $m ) { 221 if ( $m[2] == $bb_current_menu ) { 222 $bb_current_menu = $m; 223 break; 224 } 225 } 226 } 227 if ( $bb_current_submenu && !bb_current_user_can( $bb_current_submenu[1] ) || !bb_current_user_can( $bb_current_menu[1] ) ) { 228 wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) ); 229 exit; 230 } 231 } 232 233 function bb_admin_title() 234 { 235 global $bb_current_menu, $bb_current_submenu; 236 237 $title = $bb_current_menu[0] . ' ‹ ' . bb_get_option( 'name' ) . ' — ' . __( 'bbPress' ); 238 239 if ( $bb_current_submenu && $bb_current_submenu[0] !== $bb_current_menu[0] ) { 240 $title = $bb_current_submenu[0] . ' ‹ ' . $title; 241 } 242 243 echo esc_html( $title ); 244 } 245 246 function bb_admin_menu() 247 { 248 global $bb_menu, $bb_submenu, $bb_current_menu, $bb_current_submenu; 249 250 if ( !is_array( $bb_menu ) || !count( $bb_menu ) ) { 251 return ''; 252 } 253 254 $r = "\t\t\t" . '<ul id="bbAdminMenu">' . "\n"; 255 256 foreach ( $bb_menu as $key => $m ) { 257 if ( !bb_current_user_can( $m[1] ) ) { 258 continue; 259 } 260 $class = 'bb-menu'; 261 if ( isset( $m[3] ) ) { 262 $class .= ' ' . $m[3]; 263 } 264 $id = ''; 265 if ( isset( $m[4] ) ) { 266 $id .= ' id="' . $m[4] . '"'; 267 } 268 $m[0] = esc_html( $m[0] ); 269 if ( $m[2] === 'separator' ) { 270 if ( 'f' == bb_get_user_setting( 'fm' ) ) { 271 $href = '?foldmenu=0'; 272 } else { 273 $href = '?foldmenu=1'; 274 } 275 $m[0] = '<br />'; 276 $class .= ' bb-menu-separator'; 277 } elseif ( strpos( $m[2], 'http://' ) === 0 || strpos( $m[2], 'https://' ) === 0 ) { 278 $href = esc_url( $m[2] ); 279 $class .= ' bb-menu-external'; 280 } else { 281 $href = esc_url( bb_get_option( 'path' ) . 'bb-admin/' . bb_get_admin_tab_link( $m[2] ) ); 282 } 283 if ( $m[2] == $bb_current_menu[2] ) { 284 $class .= ' bb-menu-current'; 285 } 286 287 $sr = ''; 288 if ( $m[2] !== 'separator' && isset( $bb_submenu[$m[2]] ) && is_array( $bb_submenu[$m[2]] ) && count( $bb_submenu[$m[2]] ) ) { 289 $sr .= "\t\t\t\t\t" . '<div class="bb-menu-sub-wrap"><span>' . $m[0] . '</span>' . "\n"; 290 $sr .= "\t\t\t\t\t\t" . '<ul>' . "\n"; 291 $sc = 0; 292 foreach ( $bb_submenu[$m[2]] as $skey => $sm ) { 293 if ( !bb_current_user_can( $sm[1] ) ) { 294 continue; 295 } 296 if ( $sc === 0 && $sm[2] === $m[2] ) { 297 $no_submenu = true; 298 } 299 if ( $sc > 0 ) { 300 $no_submenu = false; 301 } 302 $sc++; 303 $sclass = 'bb-menu-sub'; 304 if ( isset( $sm[3] ) ) { 305 $sclass .= ' ' . $sm[3]; 306 } 307 if ( strpos( $sm[2], 'http://' ) === 0 || strpos( $sm[2], 'https://' ) === 0 ) { 308 $shref = $sm[2]; 309 $sclass .= ' bb-menu-external'; 310 } else { 311 $shref = bb_get_option( 'path' ) . 'bb-admin/' . bb_get_admin_tab_link( $sm[2] ); 312 } 313 if ( $sm[2] == $bb_current_submenu[2] ) { 314 $sclass .= ' bb-menu-sub-current'; 315 } 316 $sr .= "\t\t\t\t\t\t\t" . '<li class="' . esc_attr( trim( $sclass ) ) . '"><a href="' . esc_url( $shref ) . '">' . esc_html( $sm[0] ) . '</a></li>' . "\n"; 317 } 318 $sr .= "\t\t\t\t\t\t" . '</ul>' . "\n"; 319 $sr .= "\t\t\t\t\t" . '</div>' . "\n"; 320 } 321 322 if ( $sr && !$no_submenu ) { 323 $class .= ' bb-menu-has-submenu'; 324 if ( $m[2] == $bb_current_menu[2] ) { 325 $class .= ' bb-menu-open'; 326 } 327 } 328 329 $r .= "\t\t\t\t" . '<li' . $id . ' class="' . esc_attr( trim( $class ) ) . '"><a href="' . $href . '">'; 330 331 if ( $m[2] !== 'separator' ) { 332 $r .= '<div class="bb-menu-icon"></div>'; 333 } 334 335 $r .= '<span>' . $m[0] . '</span></a>' . "\n"; 336 337 if ( $sr && !$no_submenu ) { 338 $r .= '<div class="bb-menu-toggle"></div>'; 339 $r .= $sr; 340 } 341 342 $r .= "\t\t\t\t" . '</li>' . "\n"; 343 } 344 345 $r .= "\t\t\t" . '</ul>' . "\n"; 346 347 echo $r; 348 } 349 350 function bb_get_admin_tab_link( $tab ) 351 { 352 if ( is_array( $tab ) ) { 353 $tab = $tab[2]; 354 } 355 if ( strpos( $tab, '.php' ) !== false ) { 356 return $tab; 357 } else { 358 return 'admin-base.php?plugin=' . $tab; 359 } 360 } 361 362 /* Stats */ 363 364 function bb_get_recently_moderated_objects( $num = 5 ) { 365 $post_query = new BB_Query( 'post', array( 'per_page' => $num, 'post_status' => '-normal', 'topic_status' => 0 ) ); // post_time != moderation_time; 366 $topic_query = new BB_Query( 'topic', array( 'per_page' => $num, 'topic_status' => '-normal' ) ); // topic_time == topic_start_time != moderation_time; 367 368 $objects = array(); 369 if ( $post_query->results ) 370 foreach ( array_keys($post_query->results) as $key ) 371 $objects[bb_gmtstrtotime($post_query->results[$key]->post_time)] = array('type' => 'post', 'data' => $post_query->results[$key]); 372 if ( $topic_query->results ) 373 foreach ( array_keys($topic_query->results) as $key ) 374 $objects[bb_gmtstrtotime($topic_query->results[$key]->topic_time)] = array('type' => 'topic', 'data' => $topic_query->results[$key]); 375 krsort($objects); 376 return array_slice($objects, 0, $num); 377 } 378 379 /* Users */ 380 381 function bb_manage_user_fields( $edit_user = '' ) { 382 global $wp_roles, $wp_users_object, $bbdb; 383 384 // Cap checks 385 $user_roles = $wp_roles->role_names; 386 $can_keep_gate = bb_current_user_can( 'keep_gate' ); 387 388 if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) ) { 389 390 bb_check_admin_referer( 'user-manage' ); 391 392 // Instantiate required vars 393 $_POST = stripslashes_deep( $_POST ); 394 $create_user_errors = new WP_Error; 395 396 // User login 397 $trimmed_user_login = str_replace( ' ', '', $_POST['user_login'] ); 398 $user_login = sanitize_user( $_POST['user_login'], true ); 399 $user_meta['first_name'] = $_POST['first_name']; 400 $user_meta['last_name'] = $_POST['last_name']; 401 $user_display_name = $_POST['display_name']; 402 $user_email = $_POST['user_email']; 403 $user_url = $_POST['user_url']; 404 $user_meta['from'] = $_POST['from']; 405 $user_meta['occ'] = $_POST['occ']; 406 $user_meta['interest'] = $_POST['interest']; 407 $user_role = $_POST['userrole']; 408 $user_meta['throttle'] = $_POST['throttle']; 409 $user_pass1 = $_POST['pass1']; 410 $user_pass2 = $_POST['pass2']; 411 $user_status = 0; 412 $user_pass = false; 413 $user_url = $user_url ? bb_fix_link( $user_url ) : ''; 414 415 // Check user_login 416 if ( !isset( $_GET['action'] ) && empty( $user_login ) ) { 417 $create_user_errors->add( 'user_login', __( 'Username is a required field.' ) ); 418 } else { 419 if ( $user_login !== $trimmed_user_login ) { 420 $create_user_errors->add( 'user_login', sprintf( __( '%s is an invalid username. How\'s this one?' ), esc_html( $_POST['user_login'] ) ) ); 421 $user_login = $trimmed_user_login; 422 } 423 } 424 425 // Check email 426 if ( isset( $user_email ) && empty( $user_email ) ) 427 $create_user_errors->add( 'user_email', __( 'Email address is a required field.' ) ); 428 429 // Password Sanity Check 430 if ( ( !empty( $user_pass1 ) || !empty( $user_pass2 ) ) && $user_pass1 !== $user_pass2 ) 431 $create_user_errors->add( 'pass', __( 'You must enter the same password twice.' ) ); 432 elseif ( !isset( $_GET['action'] ) && ( empty( $user_pass1 ) && empty( $user_pass2 ) ) ) 433 $create_user_errors->add( 'pass', __( 'You must enter a password.' ) ); 434 elseif ( isset( $_GET['action'] ) && ( empty( $user_pass1 ) && empty( $user_pass2 ) ) ) 435 $user_pass = ''; 436 else 437 $user_pass = $user_pass1; 438 439 // No errors 440 if ( !$create_user_errors->get_error_messages() ) { 441 442 // Create or udpate 443 switch ( $_POST['action'] ) { 444 case 'create' : 445 $goback = bb_get_uri( 'bb-admin/users.php', array( 'created' => 'true' ), BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN ); 446 $user = $wp_users_object->new_user( compact( 'user_login', 'user_email', 'user_url', 'user_nicename', 'user_status', 'user_pass' ) ); 447 448 // Error handler 449 if ( is_wp_error( $user ) ) { 450 bb_admin_notice( $user ); 451 unset( $goback ); 452 453 // Update additional user data 454 } else { 455 // Update caps 456 bb_update_usermeta( $user['ID'], $bbdb->prefix . 'capabilities', array( $user_role => true ) ); 457 458 // Update all user meta 459 foreach ( $user_meta as $key => $value ) 460 bb_update_usermeta( $user['ID'], $key, $value ); 461 462 // Don't send email if empty 463 if ( !empty( $user_pass ) ) 464 bb_send_pass( $user['ID'], $user_pass ); 465 466 do_action( 'bb_new_user', $user['ID'], $user_pass ); 467 } 468 469 break; 470 471 case 'update' : 472 $goback = bb_get_uri( 'bb-admin/users.php', array( 'updated' => 'true' ), BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN ); 473 $user = $wp_users_object->get_user( $_GET['user_id'], array( 'output' => ARRAY_A ) ); 474 bb_update_user( $user['ID'], $user_email, $user_url, $user_display_name ); 475 476 // Don't change PW if empty 477 if ( !empty( $user_pass ) ) 478 bb_update_user_password( $user['ID'], $user_pass ); 479 480 // Error handler 481 if ( is_wp_error( $user ) ) { 482 bb_admin_notice( $user ); 483 unset( $goback ); 484 485 // Update additional user data 486 } else { 487 // Update caps 488 bb_update_usermeta( $user['ID'], $bbdb->prefix . 'capabilities', array( $user_role => true ) ); 489 490 // Update all user meta 491 foreach ( $user_meta as $key => $value ) 492 bb_update_usermeta( $user['ID'], $key, $value ); 493 494 // Don't send email if empty 495 if ( !empty( $user_pass ) ) 496 bb_send_pass( $user['ID'], $user_pass ); 497 498 do_action( 'bb_update_user', $user['ID'], $user_pass ); 499 } 500 501 break; 502 } 503 504 // Redirect 505 if ( isset( $goback ) && !empty( $goback ) ) 506 bb_safe_redirect( $goback ); 507 508 // Error handler 509 } else { 510 bb_admin_notice( $create_user_errors ); 511 } 512 } elseif ( isset( $_GET['action'] ) && $_GET['action'] == 'edit' ) { 513 if ( isset( $_GET['user_id'] ) && is_numeric( $_GET['user_id'] ) ) { 514 $disabled = true; 515 516 // Get the user 517 if ( empty( $edit_user ) ) 518 $edit_user = bb_get_user( bb_get_user_id( $_GET['user_id'] ) ); 519 520 // Instantiate required vars 521 $user_login = $edit_user->user_login; 522 $user_meta['first_name'] = $edit_user->first_name; 523 $user_meta['last_name'] = $edit_user->last_name; 524 $user_display_name = $edit_user->display_name; 525 $user_email = $edit_user->user_email; 526 $user_url = $edit_user->user_url; 527 $user_meta['from'] = $edit_user->from; 528 $user_meta['occ'] = $edit_user->occ; 529 $user_meta['interest'] = $edit_user->interest; 530 $user_role = array_search( 'true', $edit_user->capabilities ); 531 $user_meta['throttle'] = $edit_user->throttle; 532 533 // Keymasters can't demote themselves 534 if ( ( $edit_user->ID == bb_get_current_user_info( 'id' ) && $can_keep_gate ) || ( isset( $edit_user->capabilities ) && is_array( $edit_user->capabilities ) && array_key_exists( 'keymaster', $edit_user->capabilities ) && !$can_keep_gate ) ) 535 $user_roles = array( 'keymaster' => $user_roles['keymaster'] ); 536 537 // only keymasters can promote others to keymaster status 538 elseif ( !$can_keep_gate ) 539 unset( $user_roles['keymaster'] ); 540 } 541 } 542 543 // Load password strength checker 544 wp_enqueue_script( 'password-strength-meter' ); 545 wp_enqueue_script( 'profile-edit' ); 546 547 // Generate a few PW hints 548 $some_pass_hints = ''; 549 for ( $l = 3; $l != 0; $l-- ) 550 $some_pass_hints .= '<p>' . bb_generate_password() . '</p>'; 551 552 // Create the user fields 553 $user_fields = array( 554 'user_login' => array( 555 'title' => __( 'Username' ), 556 'note' => __( 'Required! Unique identifier for new user.' ), 557 'value' => $user_login, 558 'disabled' => $disabled 559 ), 560 'first_name' => array( 561 'title' => __( 'First Name' ), 562 'value' => $user_meta['first_name'] 563 ), 564 'last_name' => array( 565 'title' => __( 'Last Name' ), 566 'value' => $user_meta['last_name'] 567 ), 568 'display_name' => array( 569 'title' => __( 'Display Name' ), 570 'value' => $user_display_name 571 ), 572 'user_email' => array( 573 'title' => __( 'Email' ), 574 'note' => __( 'Required! Will be used for notifications and profile settings changes.' ), 575 'value' => $user_email 576 ), 577 'user_url' => array( 578 'title' => __( 'Website' ), 579 'class' => array( 'long', 'code' ), 580 'note' => __( 'The full URL of user\'s homepage or blog.' ), 581 'value' => $user_url 582 ), 583 'from' => array( 584 'title' => __( 'Location' ), 585 'class' => array( 'long' ), 586 'value' => $user_meta['from'] 587 ), 588 'occ' => array( 589 'title' => __( 'Occupation' ), 590 'class' => array( 'long' ), 591 'value' => $user_meta['occ'] 592 ), 593 'interest' => array( 594 'title' => __( 'Interests' ), 595 'class' => array( 'long' ), 596 'value' => $user_meta['interest'] 597 ), 598 'userrole' => array( 599 'title' => __( 'User Role' ), 600 'type' => 'select', 601 'options' => $user_roles, 602 'note' => __( 'Allow user the above privileges.' ), 603 'value' => $user_role, 604 ), 605 'pass1' => array( 606 'title' => __( 'New Password' ), 607 'type' => 'password', 608 'class' => array( 'short', 'text', 'code' ), 609 'note' => __( 'Hints: ' ) . $some_pass_hints, 610 'value' => $user_pass1, 611 ), 612 'pass2' => array( 613 'title' => __( 'Repeat New Password' ), 614 'type' => 'password', 615 'class' => array( 'short', 'text', 'code' ), 616 'note' => __( 'If you ignore hints, remember: the password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ & ).' ), 617 'value' => $user_pass2, 618 ), 619 'email_pass' => array( 620 'title' => '', 621 'type' => 'checkbox', 622 'options' => array( 623 '1' => array( 624 'label' => __( 'Email the new password.' ), 625 'attributes' => array( 'checked' => true ) 626 ) 627 ), 628 ), 629 'pass-strength-fake-input' => array( 630 'title' => __( 'Password Strength' ), 631 'type' => 'hidden', 632 ), 633 ); 634 635 return apply_filters( 'bb_manage_user_fields', $user_fields ); 636 } 637 638 // Not bbdb::prepared 639 function bb_get_ids_by_role( $role = 'moderator', $sort = 0, $page = 1, $limit = 50 ) { 640 global $bbdb, $bb_last_countable_query; 641 $sort = $sort ? 'DESC' : 'ASC'; 642 $key = $bbdb->escape( $bbdb->prefix . 'capabilities' ); 643 644 if ( !$page = abs( (int) $page ) ) 645 $page = 1; 646 $limit = abs( (int) $limit ); 647 648 $limit = ($limit * ($page - 1)) . ", $limit"; 649 650 $role = $bbdb->escape_deep($role); 651 652 if ( is_array($role) ) 653 $and_where = "( meta_value LIKE '%" . join("%' OR meta_value LIKE '%", $role) . "%' )"; 654 else 655 $and_where = "meta_value LIKE '%$role%'"; 656 $bb_last_countable_query = "SELECT user_id FROM $bbdb->usermeta WHERE meta_key = '$key' AND $and_where ORDER BY user_id $sort LIMIT $limit"; 657 658 $ids = false; 659 660 $_tuple = compact( 'ids', 'role', 'sort', 'page', 'key', 'limit', 'bb_last_countable_query' ); 661 $_tuple = apply_filters( 'bb_get_ids_by_role', $_tuple ); 662 extract( $_tuple, EXTR_OVERWRITE ); 663 664 if ( !$ids ) { 665 $ids = (array) $bbdb->get_col( $bb_last_countable_query ); 666 } 667 668 if ( $ids ) { 669 bb_cache_users( $ids ); 670 } 671 672 return $ids; 673 } 674 675 function bb_user_row( $user, $role = '', $email = false ) { 676 $actions = "<a href='" . esc_attr( get_user_profile_link( $user->ID ) ) . "'>" . __('View') . "</a>"; 677 $title = ''; 678 if ( bb_current_user_can( 'edit_user', $user_id ) ) { 679 $actions .= " | <a href='" . esc_attr( bb_get_user_admin_link( $user->ID ) ) . "'>" . __('Edit') . "</a>"; 680 $title = " title='" . esc_attr( sprintf( __( 'User ID: %d' ), $user->ID ) ) . "'"; 681 } 682 $r = "\t<tr id='user-$user->ID'" . get_alt_class("user-$role") . ">\n"; 683 $r .= "\t\t<td class=\"user\">" . bb_get_avatar( $user->ID, 32 ) . "<span class=\"row-title\"><a href='" . get_user_profile_link( $user->ID ) . "'" . $title . ">" . get_user_name( $user->ID ) . "</a></span><div><span class=\"row-actions\">$actions</span> </div></td>\n"; 684 $r .= "\t\t<td><a href='" . get_user_profile_link( $user->ID ) . "'>" . get_user_display_name( $user->ID ) . "</a></td>\n"; 685 if ( $email ) { 686 $email = bb_get_user_email( $user->ID ); 687 $r .= "\t\t<td><a href='mailto:$email'>$email</a></td>\n"; 688 } 689 690 $registered_time = bb_gmtstrtotime( $user->user_registered ); 691 if ( $registered_time < ( time() - 86400 ) ) { 692 $time = date( 'Y/m/d\<\b\r \/\>H:i:s', bb_offset_time( $registered_time ) ); 693 } else { 694 $time = sprintf( __( '%s ago' ), bb_since( $registered_time ) ); 695 } 696 697 $r .= "\t\t<td>" . $time . "</td>\n"; 698 699 if ( 700 !isset($user->capabilities) || 701 !is_array($user->capabilities) || 702 empty($user->capabilities) 703 ) { 704 $role = array( __('Inactive (no role)') ); 705 } else { 706 global $wp_roles; 707 $_roles = $wp_roles->get_names(); 708 $role = array(); 709 foreach ( $user->capabilities as $cap => $cap_set ) { 710 if (!$cap_set) { 711 continue; 712 } 713 $role[] = $_roles[$cap]; 714 } 715 if ( !count( $role ) ) { 716 $role[] = __('None'); 717 } 718 } 719 720 $r .= "\t\t<td>" . join(', ', $role) . "</td>\n\t</tr>"; 721 return $r; 722 } 723 724 // BB_User_Search class 725 // by Mark Jaquith 726 727 class BB_User_Search { 728 var $results; 729 var $search_term; 730 var $page; 731 var $raw_page; 732 var $users_per_page = 50; 733 var $first_user; 734 var $last_user; 735 var $query_limit; 736 var $total_users_for_query = 0; 737 var $search_errors; 738 var $paging_text; 739 var $paging_text_bottom; 740 741 function __construct($search_term = false, $page = 1, $roles = false ) { // constructor 742 $this->search_term = $search_term ? stripslashes($search_term) : false; 743 $this->raw_page = ( '' == $page ) ? false : (int) $page; 744 $page = (int) $page; 745 $this->page = $page < 2 ? 1 : $page; 746 $roles = (array) $roles; 747 $_roles = array(); 748 foreach ( $roles as $role ) { 749 if ( false !== $role ) { 750 $_roles[] = stripslashes( $role ); 751 } 752 } 753 $this->roles = empty( $_roles ) ? false : $_roles; 754 755 $this->prepare_query(); 756 $this->query(); 757 $this->prepare_vars_for_template_usage(); 758 $this->do_paging(); 759 } 760 761 function BB_User_Search( $search_term = false, $page = 1, $roles = false ) { 762 $this->__construct( $search_term, $page, $roles ); 763 } 764 765 function prepare_query() { 766 $this->first_user = ($this->page - 1) * $this->users_per_page; 767 } 768 769 function query() { 770 $users = bb_user_search( array( 771 'query' => $this->search_term, 772 'user_email' => true, 773 'users_per_page' => $this->users_per_page, 774 'page' => $this->page, 775 'roles' => $this->roles 776 ) ); 777 778 if ( is_wp_error($users) ) 779 $this->search_errors = $users; 780 else if ( $users ) 781 $this->results = $users; 782 // foreach ( (array) $users as $user ) 783 // $this->results[] = $user->ID; 784 785 if ( $this->results ) 786 $this->total_users_for_query = bb_count_last_query(); 787 elseif ( !is_wp_error($this->search_errors) ) 788 $this->search_errors = new WP_Error( 'no_matching_users_found', __( '<strong>No matching users were found!</strong>' ) ); 789 790 if ( is_wp_error( $this->search_errors ) ) 791 bb_admin_notice( $this->search_errors ); 792 } 793 794 function prepare_vars_for_template_usage() { 795 $this->search_term = stripslashes($this->search_term); // done with DB, from now on we want slashes gone 796 } 797 798 function do_paging() { 799 global $bb_current_submenu; 800 $displaying_num = sprintf( 801 __( '%1$s to %2$s of %3$s' ), 802 bb_number_format_i18n( ( $this->page - 1 ) * $this->users_per_page + 1 ), 803 $this->page * $this->users_per_page < $this->total_users_for_query ? bb_number_format_i18n( $this->page * $this->users_per_page ) : '<span class="total-type-count">' . bb_number_format_i18n( $this->total_users_for_query ) . '</span>', 804 '<span class="total-type-count">' . bb_number_format_i18n( $this->total_users_for_query ) . '</span>' 805 ); 806 $page_number_links = $this->total_users_for_query > $this->users_per_page ? get_page_number_links( $this->page, $this->total_users_for_query, $this->users_per_page, false ) : ''; 807 $this->paging_text = "<div class='tablenav-pages'><span class='displaying-num'>$displaying_num</span><span class=\"displaying-pages\">$page_number_links</span><div class=\"clear\"></div></div>\n"; 808 $this->paging_text_bottom = "<div class='tablenav-pages'><span class=\"displaying-pages\">$page_number_links</span><div class=\"clear\"></div></div>\n"; 809 } 810 811 function get_results() { 812 return (array) $this->results; 813 } 814 815 function page_links() { 816 echo $this->paging_text; 817 } 818 819 function results_are_paged() { 820 if ( isset($this->paging_text) && $this->paging_text ) 821 return true; 822 return false; 823 } 824 825 function is_search() { 826 if ( $this->search_term ) 827 return true; 828 return false; 829 } 830 831 function display( $show_search = true, $show_email = false ) { 832 global $wp_roles; 833 834 $r = ''; 835 836 if ( isset($this->title) ) 837 $title = $this->title; 838 elseif ( $this->is_search() ) 839 $title = sprintf(__('Users Matching "%s" by Role'), esc_html( $this->search_term )); 840 841 $h2_search = $this->search_term; 842 $h2_role = $this->roles[0]; 843 844 $roles = $wp_roles->get_names(); 845 if ( in_array( $h2_role, array_keys( $roles ) ) ) { 846 $h2_role = $roles[$h2_role]; 847 } 848 849 $h2_search = $h2_search ? ' ' . sprintf( __('containing “%s”'), esc_html( $h2_search ) ) : ''; 850 $h2_role = $h2_role ? ' ' . sprintf( __('with role “%s”'), esc_html( $h2_role ) ) : ''; 851 852 $h2_span = '<span class="subtitle">'; 853 $h2_span .= apply_filters( 'bb_user_search_description', sprintf( __( '%1$s%2$s' ), $h2_search, $h2_role ), $h2_search, $h2_role, $this ); 854 $h2_span .= '</span>'; 855 856 echo "<h2 class=\"first\">" . apply_filters( 'bb_user_search_title', __('Users') ) . $h2_span . "</h2>\n"; 857 do_action( 'bb_admin_notices' ); 858 859 if ( $show_search ) { 860 $roles = apply_filters( 'bb_user_search_form_roles', $wp_roles->get_names() ); 861 862 $r .= "<form action='' method='get' id='search' class='search-form'>\n"; 863 $r .= "<fieldset>\n"; 864 $r .= "<div>\n"; 865 $r .= "\t\t<label for='usersearch'>" . __('Search term') . "</label>"; 866 $r .= "\t\t<div><input type='text' name='usersearch' id='usersearch' class='text-input' value='" . esc_html( $this->search_term, 1) . "' /></div>\n"; 867 $r .= "</div>\n"; 868 $r .= "<div>\n"; 869 $r .= "\t\t<label for='userrole'>" . __('Role') . "</label>"; 870 $r .= "\t\t<div><select name='userrole[]' id='userrole'>\n"; 871 $r .= "\t\t\t<option value=''>" . _x( 'All', 'user roles' ) . "</option>\n"; 872 873 foreach ( $roles as $role => $display ) { 874 $selected = ''; 875 if ( is_array( $this->roles ) && in_array( $role, $this->roles ) ) { 876 $selected = ' selected="selected"'; 877 } 878 $value = esc_attr($role); 879 $display = esc_html(translate($display)); 880 $r .= "\t\t\t<option value='$value'$selected>$display</option>\n"; 881 } 882 883 $r .= "\t\t</select></div>\n"; 884 $r .= "</div>\n"; 885 886 $r = apply_filters( 'bb_user_search_form_inputs', $r, $this ); 887 888 $r .= "<div class=\"submit\">\n"; 889 $r .= "\t\t<label class='hidden' for='submit'>" . __('Search') . "</label>"; 890 $r .= "\t\t<div><input type='submit' id='submit' class='button submit-input' value='" . __('Filter') . "' /></div>\n"; 891 $r .= "</div>\n"; 892 $r .= "</fieldset>\n"; 893 $r .= "</form>\n\n"; 894 } 895 896 if ( $this->get_results() ) { 897 if ( $this->results_are_paged() ) 898 $r .= "<div class='tablenav'>\n" . $this->paging_text . "</div><div class=\"clear\"></div>\n\n"; 899 900 //foreach($roleclasses as $role => $roleclass) { 901 //ksort($roleclass); 902 //if ( !empty($role) ) 903 // $r .= "\t\t<h3>{$wp_roles->role_names[$role]}</h3>\n"; 904 //else 905 // $r .= "\t\t<h3><em>" . __('Users with no role in these forums') . "</h3>\n"; 906 $r .= "<table class='widefat'>\n"; 907 $r .= "<thead>\n"; 908 $r .= "\t<tr>\n"; 909 if ( $show_email ) { 910 $r .= "\t\t<th style='width:30%;'>" . __('Username') . "</th>\n"; 911 $r .= "\t\t<th style='width:20%;'>" . __('Name') . "</th>\n"; 912 $r .= "\t\t<th style='width:20%;'>" . __('E-mail') . "</th>\n"; 913 } else { 914 $r .= "\t\t<th style='width:40%;'>" . __('Username') . "</th>\n"; 915 $r .= "\t\t<th style='width:30%;'>" . __('Name') . "</th>\n"; 916 } 917 $r .= "\t\t<th style='width:15%;'>" . __('Registered') . "</th>\n"; 918 $r .= "\t\t<th style='width:15%;'>" . __('Role') . "</th>\n"; 919 $r .= "\t</tr>\n"; 920 $r .= "</thead>\n\n"; 921 $r .= "<tfoot>\n"; 922 $r .= "\t<tr>\n"; 923 if ( $show_email ) { 924 $r .= "\t\t<th style='width:30%;'>" . __('Username') . "</th>\n"; 925 $r .= "\t\t<th style='width:20%;'>" . __('Name') . "</th>\n"; 926 $r .= "\t\t<th style='width:20%;'>" . __('E-mail') . "</th>\n"; 927 } else { 928 $r .= "\t\t<th style='width:40%;'>" . __('Username') . "</th>\n"; 929 $r .= "\t\t<th style='width:30%;'>" . __('Name') . "</th>\n"; 930 } 931 $r .= "\t\t<th style='width:15%;'>" . __('Registered') . "</th>\n"; 932 $r .= "\t\t<th style='width:15%;'>" . __('Role') . "</th>\n"; 933 $r .= "\t</tr>\n"; 934 $r .= "</tfoot>\n\n"; 935 936 $r .= "<tbody id='role-$role'>\n"; 937 foreach ( (array) $this->get_results() as $user_object ) 938 $r .= bb_user_row($user_object, $role, $show_email); 939 $r .= "</tbody>\n"; 940 $r .= "</table>\n\n"; 941 //} 942 943 if ( $this->results_are_paged() ) 944 $r .= "<div class='tablenav bottom'>\n" . $this->paging_text_bottom . "</div><div class=\"clear\"></div>\n\n"; 945 } 946 echo $r; 947 } 948 949 } 950 951 class BB_Users_By_Role extends BB_User_Search { 952 var $role = ''; 953 var $title = ''; 954 955 function __construct($role = '', $page = '') { // constructor 956 $this->role = $role ? $role : 'member'; 957 $this->raw_page = ( '' == $page ) ? false : (int) $page; 958 $this->page = (int) ( '' == $page ) ? 1 : $page; 959 960 $this->prepare_query(); 961 $this->query(); 962 $this->do_paging(); 963 } 964 965 function BB_Users_By_Role($role = '', $page = '') { 966 $this->__construct($role, $page); 967 } 968 969 function query() { 970 if ( $_results = bb_get_ids_by_role( $this->role, 0, $this->page, $this->users_per_page ) ) { 971 $this->results = bb_get_user($_results); 972 $this->total_users_for_query = bb_count_last_query(); 973 } else 974 $this->search_errors = new WP_Error( 'no_matching_users_found', __( '<strong>No matching users were found!</strong>' ) ); 975 976 if ( is_wp_error( $this->search_errors ) ) 977 bb_admin_notice( $this->search_errors ); 978 } 979 } 980 981 /* Forums */ 982 983 // Expects forum_name, forum_desc to be pre-escaped 984 function bb_new_forum( $args ) { 985 global $bbdb; 986 if ( !bb_current_user_can( 'manage_forums' ) ) 987 return false; 988 989 $func_args = func_get_args(); 990 $defaults = array( 'forum_name' => '', 'forum_desc' => '', 'forum_parent' => 0, 'forum_order' => false, 'forum_is_category' => 0 ); 991 $args = wp_parse_args( $args, $defaults ); 992 if ( 1 < func_num_args() ) : // For back compat 993 $args['forum_name'] = $func_args[0]; 994 $args['forum_desc'] = $func_args[1]; 995 $args['forum_order'] = 2 < func_num_args() ? $func_args[2] : 0; 996 endif; 997 998 extract($args, EXTR_SKIP); 999 1000 if ( !is_numeric($forum_order) ) 1001 $forum_order = (int) $bbdb->get_var("SELECT MAX(forum_order) FROM $bbdb->forums") + 1; 1002 1003 $forum_order = (int) $forum_order; 1004 $forum_parent = (int) $forum_parent; 1005 $forum_is_category = (int) $forum_is_category; 1006 1007 $forum_name = apply_filters( 'bb_pre_forum_name', stripslashes( wp_specialchars_decode( $forum_name, ENT_QUOTES ) ) ); 1008 $forum_desc = apply_filters( 'bb_pre_forum_desc', stripslashes($forum_desc) ); 1009 1010 if ( strlen($forum_name) < 1 ) 1011 return false; 1012 1013 $forum_sql = "SELECT forum_slug FROM $bbdb->forums WHERE forum_slug = %s"; 1014 1015 $forum_slug = $_forum_slug = bb_slug_sanitize($forum_name); 1016 if ( strlen($_forum_slug) < 1 ) 1017 return false; 1018 1019 while ( is_numeric($forum_slug) || $existing_slug = $bbdb->get_var( $bbdb->prepare( $forum_sql, $forum_slug ) ) ) 1020 $forum_slug = bb_slug_increment($_forum_slug, $existing_slug); 1021 1022 $bbdb->insert( $bbdb->forums, compact( 'forum_name', 'forum_slug', 'forum_desc', 'forum_parent', 'forum_order' ) ); 1023 $forum_id = $bbdb->insert_id; 1024 if ($forum_id && $forum_is_category) 1025 bb_update_forummeta($forum_id, 'forum_is_category', $forum_is_category); 1026 wp_cache_flush( 'bb_forums' ); 1027 1028 return $forum_id; 1029 } 1030 1031 // Expects forum_name, forum_desc to be pre-escaped 1032 function bb_update_forum( $args ) { 1033 global $bbdb; 1034 if ( !bb_current_user_can( 'manage_forums' ) ) 1035 return false; 1036 1037 $func_args = func_get_args(); 1038 $defaults = array( 'forum_id' => 0, 'forum_name' => '', 'forum_slug' => '', 'forum_desc' => '', 'forum_parent' => 0, 'forum_order' => 0, 'forum_is_category' => 0 ); 1039 $fields = array( 'forum_name', 'forum_desc', 'forum_parent', 'forum_order' ); 1040 $args = wp_parse_args( $args, $defaults ); 1041 if ( 1 < func_num_args() ) : // For back compat 1042 $args['forum_id'] = $func_args[0]; 1043 $args['forum_name'] = $func_args[1]; 1044 $args['forum_desc'] = 2 < func_num_args() ? $func_args[2] : ''; 1045 $args['forum_order'] = 3 < func_num_args() && is_numeric($func_args[3]) ? $func_args[3] : 0; 1046 endif; 1047 1048 extract($args, EXTR_SKIP); 1049 1050 if ( !$forum_id = (int) $forum_id ) 1051 return false; 1052 if ( !$forum = bb_get_forum( $forum_id ) ) 1053 return false; 1054 $forum_order = (int) $forum_order; 1055 $forum_parent = (int) $forum_parent; 1056 $forum_is_category = (int) $forum_is_category; 1057 1058 $forum_name = apply_filters( 'bb_pre_forum_name', stripslashes( wp_specialchars_decode( $forum_name, ENT_QUOTES ) ), $forum_id ); 1059 $forum_desc = apply_filters( 'bb_pre_forum_desc', stripslashes($forum_desc), $forum_id ); 1060 1061 if ( strlen($forum_name) < 1 ) 1062 return false; 1063 1064 // Slug is not changing, don't update it 1065 if ( !$forum_slug || $forum_slug == $forum->forum_slug ) { 1066 // [sic] 1067 } else { 1068 $forum_slug = $_forum_slug = bb_slug_sanitize($forum_slug); 1069 if ( strlen($_forum_slug) < 1 ) 1070 return false; 1071 1072 $forum_sql = "SELECT forum_slug FROM $bbdb->forums WHERE forum_slug = %s"; 1073 1074 while ( is_numeric($forum_slug) || $existing_slug = $bbdb->get_var( $bbdb->prepare( $forum_sql, $forum_slug ) ) ) 1075 $forum_slug = bb_slug_increment($_forum_slug, $existing_slug); 1076 1077 $fields[] = 'forum_slug'; 1078 } 1079 1080 wp_cache_delete( $forum_id, 'bb_forum' ); 1081 wp_cache_flush( 'bb_forums' ); 1082 1083 $update_result = $bbdb->update( $bbdb->forums, compact( $fields ), compact( 'forum_id' ) ); 1084 1085 if ($forum_is_category) 1086 bb_update_forummeta($forum_id, 'forum_is_category', $forum_is_category); 1087 else 1088 bb_delete_forummeta($forum_id, 'forum_is_category'); 1089 1090 return $update_result; 1091 } 1092 1093 // When you delete a forum, you delete *everything* 1094 // NOT bbdb::prepared 1095 function bb_delete_forum( $forum_id ) { 1096 global $bbdb; 1097 if ( !bb_current_user_can( 'delete_forum', $forum_id ) ) 1098 return false; 1099 if ( !$forum_id = (int) $forum_id ) 1100 return false; 1101 1102 if ( !$forum = bb_get_forum( $forum_id ) ) 1103 return false; 1104 1105 if ( $topic_ids = $bbdb->get_col( $bbdb->prepare( "SELECT topic_id FROM $bbdb->topics WHERE forum_id = %d", $forum_id ) ) ) { 1106 foreach ($topic_ids as $topic_id) { 1107 bb_remove_topic_tags( $topic_id ); 1108 } 1109 $_topic_ids = join(',', array_map('intval', $topic_ids)); 1110 $bbdb->query("DELETE FROM $bbdb->posts WHERE topic_id IN ($_topic_ids) AND topic_id != 0"); 1111 $bbdb->query("DELETE FROM $bbdb->meta WHERE object_type = 'bb_topic' AND object_id IN ($_topic_ids)"); 1112 $bbdb->query( $bbdb->prepare( "DELETE FROM $bbdb->topics WHERE forum_id = %d", $forum_id ) ); 1113 } 1114 1115 $bbdb->update( $bbdb->forums, array( 'forum_parent' => $forum->forum_parent ), array( 'forum_parent' => $forum_id ) ); 1116 1117 $return = $bbdb->query( $bbdb->prepare( "DELETE FROM $bbdb->forums WHERE forum_id = %d", $forum_id ) ); 1118 1119 wp_cache_flush( 'bb_post' ); 1120 1121 if ( $topic_ids ) 1122 foreach ( $topic_ids as $topic_id ) { 1123 // should maybe just flush these groups instead 1124 wp_cache_delete( $topic_id, 'bb_topic' ); 1125 wp_cache_delete( $topic_id, 'bb_thread' ); 1126 } 1127 1128 wp_cache_delete( $forum_id, 'bb_forum' ); 1129 wp_cache_flush( 'bb_forums' ); 1130 1131 return $return; 1132 } 1133 1134 function bb_forum_row( $forum_id = 0, $echo = true, $close = false ) { 1135 global $forum, $forums_count; 1136 if ( $forum_id ) 1137 $_forum = bb_get_forum( $forum_id ); 1138 else 1139 $_forum =& $forum; 1140 1141 if ( !$_forum ) 1142 return; 1143 1144 $description = get_forum_description( $_forum->forum_id ); 1145 1146 $r = ''; 1147 if ( $close ) 1148 $r .= "\t<li id='forum-$_forum->forum_id'" . get_alt_class( 'forum', 'forum clear list-block' ) . ">\n"; 1149 $r .= "\t\t<div class='list-block posrel'>\n"; 1150 $r .= "\t\t\t<div class=\"row-title\">" . get_forum_name( $_forum->forum_id ) . "</div>\n"; 1151 if ( $description ) 1152 $r .= "\t\t\t<p class=\"row-description\">" . get_forum_description( $_forum->forum_id ) . "</p>\n"; 1153 $r .= "\t\t\t<div class=\"row-actions\"><span>\n"; 1154 $r .= "\t\t\t\t<a class='edit' href='" . get_forum_link() . "'>" . __('View') . "</a>\n"; 1155 if ( bb_current_user_can( 'manage_forums' ) ) 1156 $r .= "\t\t\t\t| <a class='edit' href='" . esc_attr( bb_get_uri('bb-admin/forums.php', array('action' => 'edit', 'id' => $_forum->forum_id), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN) ) . "'>" . __('Edit') . "</a>\n"; 1157 if ( bb_current_user_can( 'delete_forum', $_forum->forum_id ) && 1 < $forums_count ) 1158 $r .= "\t\t\t\t| <a class='delete' href='" . esc_attr( bb_get_uri('bb-admin/forums.php', array('action' => 'delete', 'id' => $_forum->forum_id), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN) ) . "'>" . __('Delete') . "</a>\n"; 1159 $r .= "\t\t\t</span> </div>\n"; 1160 $r .= "\t\t</div>\n"; 1161 if ( $close ) 1162 $r .= "\t</li>\n"; 1163 1164 if ( $echo ) 1165 echo $r; 1166 return $r; 1167 } 1168 1169 function bb_forum_form( $forum_id = 0 ) { 1170 $forum_id = (int) $forum_id; 1171 if ( $forum_id && !$forum = bb_get_forum( $forum_id ) ) { 1172 return; 1173 } 1174 1175 $forum_name = ''; 1176 $forum_slug = ''; 1177 $forum_description = ''; 1178 $forum_position = ''; 1179 1180 if ( $forum_id ) { 1181 $forum_name = get_forum_name( $forum_id ); 1182 $forum_slug = apply_filters('editable_slug', $forum->forum_slug); 1183 $forum_description = get_forum_description( $forum_id ); 1184 $forum_position = get_forum_position( $forum_id ); 1185 $legend = __( 'Edit Forum' ); 1186 $submit = __( 'Save Changes' ); 1187 $action = 'update'; 1188 } else { 1189 $legend = __( 'Add Forum' ); 1190 $submit = __( 'Add Forum' ); 1191 $action = 'add'; 1192 } 1193 1194 $forum_options = array( 1195 'forum_name' => array( 1196 'title' => __( 'Name' ), 1197 'value' => $forum_name 1198 ), 1199 'forum_slug' => array( 1200 'title' => __( 'Slug' ), 1201 'value' => $forum_slug 1202 ), 1203 'forum_desc' => array( 1204 'title' => __( 'Description' ), 1205 'value' => $forum_description, 1206 'class' => 'long' 1207 ), 1208 'forum_parent' => array( 1209 'title' => __( 'Parent' ), 1210 'type' => 'select', 1211 'options' => bb_get_forum_dropdown( array( 1212 'cut_branch' => $forum_id, 1213 'id' => 'forum_parent', 1214 'none' => true, 1215 'selected' => $forum_id ? get_forum_parent( $forum_id ) : 0, 1216 'disable_categories' => 0, 1217 'options_only' => true 1218 ) ) 1219 ), 1220 'forum_order' => array( 1221 'title' => __( 'Position' ), 1222 'value' => $forum_position, 1223 'class' => 'short' 1224 ), 1225 'forum_is_category' => array( 1226 'title' => __( 'Category' ), 1227 'type' => 'checkbox', 1228 'options' => array( 1229 1 => array( 1230 'label' => __( 'Make this forum a category' ), 1231 'value' => bb_get_forum_is_category( $forum_id ), 1232 ) 1233 ), 1234 'note' => __( 'Categories are forums where new topics cannot be created. Categories usually contain a group of sub-forums.' ) 1235 ) 1236 ); 1237 1238 if ( !$forum_id ) { 1239 unset( $forum_options['forum_slug'] ); 1240 unset( $forum_options['forum_order'] ); 1241 } 1242 1243 ?> 1244 <form class="settings" method="post" id="<?php echo $action; ?>-forum" action="<?php bb_uri('bb-admin/bb-forum.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>" class="add:forum-list: forum-form"> 1245 <fieldset> 1246 <legend><?php echo $legend; ?></legend> 1247 <?php 1248 foreach ( $forum_options as $option => $args ) { 1249 bb_option_form_element( $option, $args ); 1250 } 1251 ?> 1252 <fieldset class="submit"> 1253 <?php if ( $forum_id ) : ?> 1254 <input type="hidden" name="forum_id" value="<?php echo $forum_id; ?>" /> 1255 <?php endif; ?> 1256 <?php bb_nonce_field( 'order-forums', 'order-nonce' ); ?> 1257 <?php bb_nonce_field( $action . '-forum' ); ?> 1258 <input type="hidden" name="action" value="<?php echo $action; ?>" /> 1259 <input class="submit" type="submit" name="submit" value="<?php echo $submit; ?>" /> 1260 </fieldset> 1261 </fieldset> 1262 </form> 1263 <?php 1264 } 1265 1266 class BB_Walker_ForumAdminlistitems extends BB_Walker { 1267 var $tree_type = 'forum'; 1268 var $db_fields = array ('parent' => 'forum_parent', 'id' => 'forum_id'); //TODO: decouple this 1269 1270 function start_lvl($output, $depth) { 1271 $indent = str_repeat("\t", $depth) . ' '; 1272 $output .= $indent . "<ul id='forum-root-$this->forum_id' class='list-block holder'>\n"; 1273 return $output; 1274 } 1275 1276 function end_lvl($output, $depth) { 1277 $indent = str_repeat("\t", $depth) . ' '; 1278 $output .= $indent . "</ul>\n"; 1279 return $output; 1280 } 1281 1282 function start_el($output, $forum, $depth) { 1283 $this->forum_id = $forum->forum_id; 1284 $indent = str_repeat("\t", $depth + 1); 1285 $output .= $indent . "<li id='forum-$this->forum_id'" . get_alt_class( 'forum', 'forum clear list-block' ) . ">\n"; 1286 1287 return $output; 1288 } 1289 1290 function end_el($output, $forum, $depth) { 1291 $indent = str_repeat("\t", $depth + 1); 1292 $output .= $indent . "</li>\n"; 1293 return $output; 1294 } 1295 } 1296 1297 1298 1299 /* Topics */ 1300 1301 function bb_move_forum_topics( $from_forum_id, $to_forum_id ) { 1302 global $bbdb; 1303 1304 $from_forum_id = (int) $from_forum_id ; 1305 $to_forum_id = (int) $to_forum_id; 1306 1307 add_filter('get_forum_where', 'bb_no_where'); // Just in case 1308 1309 $from_forum = bb_get_forum( $from_forum_id ); 1310 if ( !$to_forum = bb_get_forum( $to_forum_id ) ) 1311 return false; 1312 1313 $posts = $to_forum->posts + ( $from_forum ? $from_forum->posts : 0 ); 1314 $topics = $to_forum->topics + ( $from_forum ? $from_forum->topics : 0 ); 1315 1316 $bbdb->update( $bbdb->forums, compact( 'topics', 'posts' ), array( 'forum_id' => $to_forum_id ) ); 1317 $bbdb->update( $bbdb->forums, array( 'topics' => 0, 'posts' => 0 ), array( 'forum_id' => $from_forum_id ) ); 1318 $bbdb->update( $bbdb->posts, array( 'forum_id' => $to_forum_id ), array( 'forum_id' => $from_forum_id ) ); 1319 $topic_ids = $bbdb->get_col( $bbdb->prepare( "SELECT topic_id FROM $bbdb->topics WHERE forum_id = %d", $from_forum_id ) ); 1320 $return = $bbdb->update( $bbdb->topics, array( 'forum_id' => $to_forum_id ), array( 'forum_id' => $from_forum_id ) ); 1321 1322 wp_cache_flush( 'bb_post' ); 1323 1324 if ( $topic_ids ) 1325 foreach ( $topic_ids as $topic_id ) { 1326 // should maybe just flush these groups 1327 wp_cache_delete( $topic_id, 'bb_topic' ); 1328 wp_cache_delete( $topic_id, 'bb_thread' ); 1329 } 1330 1331 wp_cache_delete( $from_forum_id, 'bb_forum' ); 1332 wp_cache_delete( $to_forum_id, 'bb_forum' ); 1333 wp_cache_flush( 'bb_forums' ); 1334 1335 return $return; 1336 } 1337 1338 /* Posts */ 1339 1340 function bb_admin_list_posts() { 1341 global $bb_posts, $bb_post; 1342 1343 if ( !$bb_posts ) { 1344 ?> 1345 <p class="no-results"><?php _e('No posts found.'); ?></p> 1346 <?php 1347 } else { 1348 ?> 1349 <table id="posts-list" class="widefat" cellspacing="0" cellpadding="0"> 1350 <thead> 1351 <tr> 1352 <th scope="col" class="check-column"><input type="checkbox" /></th> 1353 <th scope="col"><?php _e( 'Post' ); ?></th> 1354 <th scope="col"><?php _e( 'Author' ); ?></th> 1355 <th scope="col"><?php _e( 'Topic' ); ?></th> 1356 <th scope="col"><?php _e( 'Date' ); ?></th> 1357 </tr> 1358 </thead> 1359 <tfoot> 1360 <tr> 1361 <th scope="col" class="check-column"><input type="checkbox" /></th> 1362 <th scope="col"><?php _e( 'Post' ); ?></th> 1363 <th scope="col"><?php _e( 'Author' ); ?></th> 1364 <th scope="col"><?php _e( 'Topic' ); ?></th> 1365 <th scope="col"><?php _e( 'Date' ); ?></th> 1366 </tr> 1367 </tfoot> 1368 <tbody> 1369 <?php 1370 foreach ( $bb_posts as $bb_post ) { 1371 ?> 1372 <tr id="post-<?php post_id(); ?>"<?php alt_class('post', post_del_class()); ?>> 1373 <td class="check-column"><input type="checkbox" name="post[]" value="<?php post_id(); ?>" /></td> 1374 <td class="post"> 1375 <?php post_text(); ?> 1376 <div> 1377 <span class="row-actions"> 1378 <a href="<?php echo esc_url( get_post_link() ); ?>"><?php _e( 'View' ); ?></a> 1379 <?php 1380 bb_post_admin( array( 1381 'before_each' => ' | ', 1382 'each' => array( 1383 'undelete' => array( 1384 'before' => ' ' 1385 ) 1386 ), 1387 'last_each' => array( 1388 'before' => ' | ' 1389 ) 1390 ) ); 1391 ?> 1392 </span> 1393 </div> 1394 </td> 1395 1396 <td class="author"> 1397 <?php if ( get_post_author_id() ) : ?> 1398 1399 <a href="<?php user_profile_link( get_post_author_id() ); ?>"> 1400 <?php post_author_avatar( '16' ); ?> 1401 <?php post_author(); ?> 1402 </a> 1403 1404 <?php else : ?> 1405 1406 <span> 1407 <?php post_author_avatar( '16' ); ?> 1408 <?php post_author(); ?> 1409 </span> 1410 1411 <?php endif; ?> 1412 </td> 1413 1414 <td class="topic"> 1415 <a href="<?php topic_link( $bb_post->topic_id ); ?>"><?php topic_title( $bb_post->topic_id ); ?></a> 1416 </td> 1417 1418 <td class="date"> 1419 <?php 1420 if ( bb_get_post_time( 'U' ) < ( time() - 86400 ) ) { 1421 bb_post_time( 'Y/m/d\<\b\r \/\>H:i:s' ); 1422 } else { 1423 printf( __( '%s ago' ), bb_get_post_time( 'since' ) ); 1424 } 1425 ?> 1426 </td> 1427 </tr> 1428 <?php 1429 } 1430 ?> 1431 </tbody> 1432 </table> 1433 <?php 1434 } 1435 } 1436 1437 /* Recounts */ 1438 1439 function bb_recount_list() 1440 { 1441 global $recount_list; 1442 $recount_list = array( 1443 5 => array( 'topic-posts', __( 'Count posts of every topic' ) ), 1444 6 => array( 'topic-voices', __( 'Count voices of every topic' ) ), 1445 10 => array( 'topic-deleted-posts', __( 'Count deleted posts on every topic' ) ), 1446 15 => array( 'forums', __( 'Count topics and posts in every forum' ) ), 1447 20 => array( 'topics-replied', __( 'Count topics to which each user has replied' ) ), 1448 25 => array( 'topic-tag-count', __( 'Count tags for every topic' ) ), 1449 30 => array( 'tags-tag-count', __( 'Count topics for every tag' ) ), 1450 35 => array( 'tags-delete-empty', __( 'Delete tags with no topics' ) ), 1451 40 => array( 'clean-favorites', __( 'Remove deleted topics from users\' favorites' ) ) 1452 ); 1453 do_action( 'bb_recount_list' ); 1454 ksort( $recount_list ); 1455 return $recount_list; 1456 } 1457 1458 /* Themes */ 1459 1460 function bb_get_current_theme_data( $property = 'all' ) { 1461 if (!$property) { 1462 $property = 'all'; 1463 } 1464 $directory = bb_get_active_theme_directory(); 1465 $stylesheet = $directory . 'style.css'; 1466 if (file_exists($stylesheet)) { 1467 $data = bb_get_theme_data($stylesheet); 1468 } 1469 if ($property == 'all') { 1470 return $data; 1471 } elseif (isset($data[$property])) { 1472 return $data[$property]; 1473 } else { 1474 return false; 1475 } 1476 } 1477 1478 // Output sanitized for display 1479 function bb_get_theme_data( $theme_file ) 1480 { 1481 if ( strpos($theme_file, '#') !== false ) { 1482 $theme_file = bb_get_theme_directory( $theme_file ) . 'style.css'; 1483 } 1484 $theme_code = implode( '', file( $theme_file ) ); 1485 $theme_code = str_replace ( '\r', '\n', $theme_code ); 1486 // Grab just the first commented area from the file 1487 preg_match( '|/\*(.*)\*/|msU', $theme_code, $theme_block ); 1488 $theme_data = trim( $theme_block[1] ); 1489 preg_match( '|Theme Name:(.*)|i', $theme_data, $theme_name ); 1490 preg_match( '|Theme URI:(.*)|i', $theme_data, $theme_uri ); 1491 preg_match( '|Description:(.*)|i', $theme_data, $description ); 1492 preg_match( '|Author:(.*)|i', $theme_data, $author_name ); 1493 preg_match( '|Author URI:(.*)|i', $theme_data, $author_uri ); 1494 preg_match( '|Ported By:(.*)|i', $theme_data, $porter_name ); 1495 preg_match( '|Porter URI:(.*)|i', $theme_data, $porter_uri ); 1496 // preg_match( '|Template:(.*)|i', $theme_data, $template ); 1497 if ( preg_match( '|Version:(.*)|i', $theme_data, $version ) ) 1498 $version = esc_html( trim( $version[1] ) ); 1499 else 1500 $version =''; 1501 if ( preg_match('|Status:(.*)|i', $theme_data, $status) ) 1502 $status = esc_html( trim($status[1]) ); 1503 else 1504 $status = 'publish'; 1505 1506 $description = trim($description[1]); 1507 $description = bb_encode_bad( $description ); 1508 $description = bb_code_trick( $description ); 1509 $description = force_balance_tags( $description ); 1510 $description = bb_filter_kses( $description ); 1511 $description = bb_autop( $description ); 1512 1513 $name = $theme_name[1]; 1514 $name = esc_html( trim($name) ); 1515 $theme = $name; 1516 1517 if ( $author_name || $author_uri ) { 1518 if ( empty($author_uri[1]) ) { 1519 $author = bb_filter_kses( trim($author_name[1]) ); 1520 } else { 1521 $author = '<a href="' . esc_url( trim($author_uri[1]) ) . '" title="' . esc_attr__( 'Visit author homepage' ) . '">' . bb_filter_kses( trim($author_name[1]) ) . '</a>'; 1522 } 1523 } else { 1524 $author = ''; 1525 } 1526 1527 if ( $porter_name || $porter_uri ) { 1528 if ( empty($porter_uri[1]) ) { 1529 $porter = bb_filter_kses( trim($porter_name[1]) ); 1530 } else { 1531 $porter = '<a href="' . esc_url( trim($porter_uri[1]) ) . '" title="' . esc_attr__( 'Visit porter homepage' ) . '">' . bb_filter_kses( trim($porter_name[1]) ) . '</a>'; 1532 } 1533 } else { 1534 $porter = ''; 1535 } 1536 1537 global $bb; 1538 1539 // Normalise the path to the theme 1540 $theme_file = str_replace( '\\', '/', $theme_file ); 1541 1542 foreach ( $bb->theme_locations as $_name => $_data ) { 1543 $_directory = str_replace( '\\', '/', $_data['dir'] ); 1544 if ( 0 === strpos( $theme_file, $_directory ) ) { 1545 $location = $_name; 1546 break; 1547 } 1548 } 1549 1550 return array( 1551 'Location' => $location, 1552 'Name' => $name, 1553 'Title' => $theme, 1554 'Description' => $description, 1555 'Author' => $author, 1556 'Porter' => $porter, 1557 'Version' => $version, 1558 // 'Template' => $template[1], 1559 'Status' => $status, 1560 'URI' => esc_url( $theme_uri[1] ) 1561 ); 1562 } 1563 1564 if ( !function_exists( 'checked' ) ) : 1565 function checked( $checked, $current) { 1566 if ( $checked == $current) 1567 echo ' checked="checked"'; 1568 } 1569 endif; 1570 1571 if ( !function_exists( 'selected' ) ) : 1572 function selected( $selected, $current) { 1573 if ( $selected === $current) 1574 echo ' selected="selected"'; 1575 } 1576 endif; 1577 1578 /* Options */ 1579 1580 function bb_option_form_element( $name = 'name', $args = null ) { 1581 global $bb_hardcoded; 1582 1583 $defaults = array( 1584 'title' => 'title', 1585 'type' => 'text', 1586 'value' => false, 1587 'options' => false, 1588 'message' => false, 1589 'class' => false, 1590 'default' => false, 1591 'before' => '', 1592 'after' => '', 1593 'note' => false, 1594 'attributes' => false, 1595 'disabled' => false, 1596 ); 1597 1598 $args = wp_parse_args( $args, $defaults ); 1599 1600 $id = str_replace( array( '_', '[', ']' ), array( '-', '-', '' ), $name ); 1601 if ( false !== strpos( $name, '[' ) ) { 1602 list( $option_name, $option_key ) = preg_split( '/[\[\]]/', $name, -1, PREG_SPLIT_NO_EMPTY ); 1603 $option = bb_get_option( $option_name ); 1604 $value = false === $args['value'] ? esc_attr( $option[$option_key] ) : esc_attr( $args['value'] ); 1605 $hardcoded = isset( $bb_hardcoded[$option_name][$option_key] ); 1606 } else { 1607 $value = false === $args['value'] ? bb_get_form_option( $name ) : esc_attr( $args['value'] ); 1608 $hardcoded = isset( $bb_hardcoded[$name] ); 1609 } 1610 1611 $class = $args['class'] ? (array) $args['class'] : array(); 1612 array_unshift( $class, $args['type'] ); 1613 1614 if ( $hardcoded || $args['disabled'] ) 1615 $disabled = ' disabled="disabled"'; 1616 else 1617 $disabled = false; 1618 1619 if ( $args['attributes'] ) { 1620 $attributes = array(); 1621 foreach ( $args['attributes'] as $k => $v ) 1622 $attributes[] = "$k='$v'"; 1623 $attributes = ' ' . join( ' ', $attributes ); 1624 } else { 1625 $attributes = ''; 1626 } 1627 1628 ?> 1629 1630 <div id="option-<?php echo $id; ?>"<?php if ( !empty( $disabled ) ) echo ' class="disabled"'; ?>> 1631 <?php 1632 switch ( $args['type'] ) { 1633 case 'radio' : 1634 case 'checkbox' : 1635 case 'message' : 1636 ?> 1637 <div class="label"> 1638 <?php echo $args['title']; ?> 1639 </div> 1640 1641 <?php 1642 break; 1643 case 'select' : 1644 default : 1645 ?> 1646 <label for="<?php echo $id; ?>"> 1647 <?php echo $args['title']; ?> 1648 </label> 1649 1650 <?php 1651 break; 1652 } 1653 ?> 1654 <div class="inputs"> 1655 1656 <?php 1657 if ( $args['before'] ) { 1658 echo '<span class="before">' . $args['before'] . '</span>'; 1659 } 1660 switch ( $args['type'] ) { 1661 case 'select' : 1662 echo "<select$disabled class='" . join( ' ', $class ) . "' name='$name' id='$id'$attributes>\n"; 1663 if ( is_array( $args['options'] ) ) { 1664 foreach ( $args['options'] as $option => $label ) 1665 echo "\t<option value='$option'" . ( $value == $option ? " selected='selected'" : '' ) . ">$label</option>\n"; 1666 } elseif ( is_string( $args['options'] ) ) { 1667 echo $args['options'] . "\n"; 1668 } 1669 echo "</select>\n"; 1670 break; 1671 case 'radio' : 1672 case 'checkbox' : 1673 if ( is_array( $args['options'] ) ) { 1674 $_id = 0; 1675 if ( 'radio' === $args['type'] && !in_array( $value, array_keys( $args['options'] ) ) && empty( $value ) ) { 1676 $use_first_value = true; 1677 } 1678 $type = $args['type']; 1679 foreach ( $args['options'] as $option => $label ) { 1680 if ( $use_first_value ) { 1681 $use_first_value = false; 1682 $value = $option; 1683 } 1684 if ( is_array( $label ) ) { 1685 if ( isset( $label['attributes'] ) ) { 1686 $attributes = array(); 1687 foreach ( $label['attributes'] as $k => $v ) 1688 $attributes[] = "$k='$v'"; 1689 $attributes = ' ' . join( ' ', $attributes ); 1690 } else { 1691 $attributes = ''; 1692 } 1693 if ( isset( $label['name'] ) ) { 1694 $name = $label['name']; 1695 $id = str_replace( array( '_', '[', ']' ), array( '-', '-', '' ), $name ); 1696 $hardcoded = isset( $bb_hardcoded[$name] ); 1697 } 1698 if ( isset( $label['value'] ) ) { 1699 $_value = $label['value']; 1700 } else { 1701 $_value = $args['value']; 1702 } 1703 $value = false === $_value ? bb_get_form_option( $name ) : esc_attr( $_value ); 1704 $label = $label['label']; 1705 } 1706 echo "<label class=\"{$type}s\"><input$disabled type='$type' class='" . join( ' ', $class ) . "' name='$name' id='$id-$_id' value='$option'" . ( $value == $option ? " checked='checked'" : '' ) . "{$attributes} /> $label</label>\n"; 1707 $_id++; 1708 } 1709 } elseif ( is_string( $args['options'] ) ) { 1710 echo $args['options'] . "\n"; 1711 } 1712 break; 1713 case 'message' : 1714 if ( $args['message'] ) { 1715 echo $args['message']; 1716 } 1717 break; 1718 default : 1719 echo "<input$disabled type='$args[type]' class='" . join( ' ', $class ) . "' name='$name' id='$id' value='$value'$attributes />\n"; 1720 break; 1721 } 1722 if ( $args['after'] ) { 1723 echo '<span class="after">' . $args['after'] . '</span>'; 1724 } 1725 1726 if ( $args['note'] ) { 1727 foreach ( (array) $args['note'] as $note ) { 1728 ?> 1729 1730 <p><?php echo $note; ?></p> 1731 1732 <?php 1733 } 1734 } 1735 ?> 1736 1737 </div> 1738 </div> 1739 1740 <?php 1741 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Dec 7 01:01:35 2017 | Cross-referenced by PHPXref 0.7.1 |