Advertisement
Guest User

Untitled

a guest
May 21st, 2012
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.33 KB | None | 0 0
  1.  
  2. Code in header.php file in the Snazzy theme folder:
  3.  
  4. `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  5.  
  6. <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
  7. <head profile="http://gmpg.org/xfn/11">
  8. <meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ) ?>; charset=<?php bloginfo( 'charset' ) ?>" />
  9. <title><?php wp_title( '|', true, 'right' ); bloginfo( 'name' ); ?></title>
  10.  
  11. <?php do_action( 'bp_head' ) ?>
  12. <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
  13. <link rel="pingback" href="<?php bloginfo( 'pingback_url' ) ?>" />
  14.  
  15. <?php
  16. if ( is_singular() && bp_is_blog_page() && get_option( 'thread_comments' ) )
  17. wp_enqueue_script( 'comment-reply' );
  18.  
  19. wp_head();
  20. ?>
  21. </head>
  22.  
  23. <body <?php body_class() ?> id="bp-default">
  24.  
  25. <?php do_action( 'bp_before_header' ) ?>
  26.  
  27. <div id="header">
  28. <div id="search-bar" role="search">
  29. <div class="padder">
  30. <h1 id="logo" role="banner"><a href="<?php echo home_url(); ?>" title="<?php _ex( 'Home', 'Home page banner link title', 'buddypress' ); ?>"><?php bp_site_name(); ?></a></h1>
  31.  
  32. <form action="<?php echo bp_search_form_action() ?>" method="post" id="search-form">
  33. <label for="search-terms" class="accessibly-hidden"><?php _e( 'Search for:', 'buddypress' ); ?></label>
  34. <input type="text" id="search-terms" name="search-terms" value="<?php echo isset( $_REQUEST['s'] ) ? esc_attr( $_REQUEST['s'] ) : ''; ?>" />
  35.  
  36. <?php echo bp_search_form_type_select() ?>
  37.  
  38. <input type="submit" name="search-submit" id="search-submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
  39.  
  40. <?php wp_nonce_field( 'bp_search_form' ) ?>
  41.  
  42. </form><!-- #search-form -->
  43.  
  44. <?php do_action( 'bp_search_login_bar' ) ?>
  45.  
  46. </div><!-- .padder -->
  47. </div><!-- #search-bar -->
  48.  
  49. <div id="navigation" role="navigation">
  50. <?php wp_nav_menu( array( 'container' => false, 'menu_id' => 'nav', 'theme_location' => 'primary', 'fallback_cb' => 'bp_dtheme_main_nav' ) ); ?>
  51. </div>
  52.  
  53. <?php do_action( 'bp_header' ) ?>
  54.  
  55. </div><!-- #header -->
  56.  
  57. <?php do_action( 'bp_after_header' ) ?>
  58. <?php do_action( 'bp_before_container' ) ?>
  59.  
  60. <div id="container">`
  61.  
  62. Code of functions.php in the Snazzy folder:
  63.  
  64. `<?php
  65. if ( !function_exists( 'bp_dtheme_enqueue_styles' ) ) :
  66. function bp_dtheme_enqueue_styles() {}
  67. endif;
  68. ?>`
  69.  
  70.  
  71.  
  72. Code of header.php in the BuddyPress default folder:
  73.  
  74. `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  75.  
  76. <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
  77. <head profile="http://gmpg.org/xfn/11">
  78. <meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ) ?>; charset=<?php bloginfo( 'charset' ) ?>" />
  79. <title><?php wp_title( '|', true, 'right' ); bloginfo( 'name' ); ?></title>
  80.  
  81. <?php do_action( 'bp_head' ) ?>
  82.  
  83. <link rel="pingback" href="<?php bloginfo( 'pingback_url' ) ?>" />
  84.  
  85. <?php
  86. if ( is_singular() && bp_is_blog_page() && get_option( 'thread_comments' ) )
  87. wp_enqueue_script( 'comment-reply' );
  88.  
  89. wp_head();
  90. ?>
  91. </head>
  92.  
  93. <body <?php body_class() ?> id="bp-default">
  94.  
  95. <?php do_action( 'bp_before_header' ) ?>
  96.  
  97. <div id="header">
  98. <div id="search-bar" role="search">
  99. <div class="padder">
  100. <h1 id="logo" role="banner"><a href="<?php echo home_url(); ?>" title="<?php _ex( 'Home', 'Home page banner link title', 'buddypress' ); ?>"><?php bp_site_name(); ?></a></h1>
  101.  
  102. <form action="<?php echo bp_search_form_action() ?>" method="post" id="search-form">
  103. <label for="search-terms" class="accessibly-hidden"><?php _e( 'Search for:', 'buddypress' ); ?></label>
  104. <input type="text" id="search-terms" name="search-terms" value="<?php echo isset( $_REQUEST['s'] ) ? esc_attr( $_REQUEST['s'] ) : ''; ?>" />
  105.  
  106. <?php echo bp_search_form_type_select() ?>
  107.  
  108. <input type="submit" name="search-submit" id="search-submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
  109.  
  110. <?php wp_nonce_field( 'bp_search_form' ) ?>
  111.  
  112. </form><!-- #search-form -->
  113.  
  114. <?php do_action( 'bp_search_login_bar' ) ?>
  115.  
  116. </div><!-- .padder -->
  117. </div><!-- #search-bar -->
  118.  
  119. <div id="navigation" role="navigation">
  120. <?php wp_nav_menu( array( 'container' => false, 'menu_id' => 'nav', 'theme_location' => 'primary', 'fallback_cb' => 'bp_dtheme_main_nav' ) ); ?>
  121. </div>
  122.  
  123. <?php do_action( 'bp_header' ) ?>
  124.  
  125. </div><!-- #header -->
  126.  
  127. <?php do_action( 'bp_after_header' ) ?>
  128. <?php do_action( 'bp_before_container' ) ?>
  129.  
  130. <div id="container">
  131. `
  132.  
  133. Code of functions.php in the BuddyPress default folder:
  134. `<?php
  135. /**
  136. * BP-Default theme functions and definitions
  137. *
  138. * Sets up the theme and provides some helper functions. Some helper functions
  139. * are used in the theme as custom template tags. Others are attached to action and
  140. * filter hooks in WordPress and BuddyPress to change core functionality.
  141. *
  142. * The first function, bp_dtheme_setup(), sets up the theme by registering support
  143. * for various features in WordPress, such as post thumbnails and navigation menus, and
  144. * for BuddyPress, action buttons and javascript localisation.
  145. *
  146. * When using a child theme (see http://codex.wordpress.org/Theme_Development, http://codex.wordpress.org/Child_Themes
  147. * and http://codex.buddypress.org/theme-development/building-a-buddypress-child-theme/), you can override
  148. * certain functions (those wrapped in a function_exists() call) by defining them first in your
  149. * child theme's functions.php file. The child theme's functions.php file is included before the
  150. * parent theme's file, so the child theme functions would be used.
  151. *
  152. * Functions that are not pluggable (not wrapped in function_exists()) are instead attached
  153. * to a filter or action hook. The hook can be removed by using remove_action() or
  154. * remove_filter() and you can attach your own function to the hook.
  155. *
  156. * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
  157. *
  158. * @package BuddyPress
  159. * @subpackage BP-Default
  160. * @since 1.2
  161. */
  162.  
  163. if ( !function_exists( 'bp_is_active' ) )
  164. return;
  165.  
  166. // If BuddyPress is not activated, switch back to the default WP theme
  167. if ( !defined( 'BP_VERSION' ) )
  168. switch_theme( WP_DEFAULT_THEME, WP_DEFAULT_THEME );
  169.  
  170. /**
  171. * Set the content width based on the theme's design and stylesheet.
  172. *
  173. * Used to set the width of images and content. Should be equal to the width the theme
  174. * is designed for, generally via the style.css stylesheet.
  175. */
  176. if ( ! isset( $content_width ) )
  177. $content_width = 591;
  178.  
  179. if ( !function_exists( 'bp_dtheme_setup' ) ) :
  180. /**
  181. * Sets up theme defaults and registers support for various WordPress and BuddyPress features.
  182. *
  183. * Note that this function is hooked into the after_setup_theme hook, which runs
  184. * before the init hook. The init hook is too late for some features, such as indicating
  185. * support post thumbnails.
  186. *
  187. * To override bp_dtheme_setup() in a child theme, add your own bp_dtheme_setup to your child theme's
  188. * functions.php file.
  189. *
  190. * @global object $bp Global BuddyPress settings object
  191. * @since 1.5
  192. */
  193. function bp_dtheme_setup() {
  194. global $bp;
  195.  
  196. // Load the AJAX functions for the theme
  197. require( TEMPLATEPATH . '/_inc/ajax.php' );
  198.  
  199. // This theme styles the visual editor with editor-style.css to match the theme style.
  200. add_editor_style();
  201.  
  202. // This theme uses post thumbnails
  203. add_theme_support( 'post-thumbnails' );
  204.  
  205. // Add default posts and comments RSS feed links to head
  206. add_theme_support( 'automatic-feed-links' );
  207.  
  208. // Add responsive layout support to bp-default without forcing child
  209. // themes to inherit it if they don't want to
  210. add_theme_support( 'bp-default-responsive' );
  211.  
  212. // This theme uses wp_nav_menu() in one location.
  213. register_nav_menus( array(
  214. 'primary' => __( 'Primary Navigation', 'buddypress' ),
  215. ) );
  216.  
  217. // This theme allows users to set a custom background
  218. add_custom_background( 'bp_dtheme_custom_background_style' );
  219.  
  220. // Add custom header support if allowed
  221. if ( !defined( 'BP_DTHEME_DISABLE_CUSTOM_HEADER' ) ) {
  222. define( 'HEADER_TEXTCOLOR', 'FFFFFF' );
  223.  
  224. // The height and width of your custom header. You can hook into the theme's own filters to change these values.
  225. // Add a filter to bp_dtheme_header_image_width and bp_dtheme_header_image_height to change these values.
  226. define( 'HEADER_IMAGE_WIDTH', apply_filters( 'bp_dtheme_header_image_width', 401 ) );
  227. define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'bp_dtheme_header_image_height', 80 ) );
  228.  
  229. // We'll be using post thumbnails for custom header images on posts and pages. We want them to be 1250 pixels wide by 133 pixels tall.
  230. // Larger images will be auto-cropped to fit, smaller ones will be ignored.
  231. set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
  232.  
  233. // Add a way for the custom header to be styled in the admin panel that controls custom headers.
  234. add_custom_image_header( 'bp_dtheme_header_style', 'bp_dtheme_admin_header_style' );
  235. }
  236.  
  237. if ( !is_admin() ) {
  238. // Register buttons for the relevant component templates
  239. // Friends button
  240. if ( bp_is_active( 'friends' ) )
  241. add_action( 'bp_member_header_actions', 'bp_add_friend_button' );
  242.  
  243. // Activity button
  244. if ( bp_is_active( 'activity' ) )
  245. add_action( 'bp_member_header_actions', 'bp_send_public_message_button' );
  246.  
  247. // Messages button
  248. if ( bp_is_active( 'messages' ) )
  249. add_action( 'bp_member_header_actions', 'bp_send_private_message_button' );
  250.  
  251. // Group buttons
  252. if ( bp_is_active( 'groups' ) ) {
  253. add_action( 'bp_group_header_actions', 'bp_group_join_button' );
  254. add_action( 'bp_group_header_actions', 'bp_group_new_topic_button' );
  255. add_action( 'bp_directory_groups_actions', 'bp_group_join_button' );
  256. }
  257.  
  258. // Blog button
  259. if ( bp_is_active( 'blogs' ) )
  260. add_action( 'bp_directory_blogs_actions', 'bp_blogs_visit_blog_button' );
  261. }
  262. }
  263. add_action( 'after_setup_theme', 'bp_dtheme_setup' );
  264. endif;
  265.  
  266. if ( !function_exists( 'bp_dtheme_enqueue_scripts' ) ) :
  267. /**
  268. * Enqueue theme javascript safely
  269. *
  270. * @see http://codex.wordpress.org/Function_Reference/wp_enqueue_script
  271. * @since 1.5
  272. */
  273. function bp_dtheme_enqueue_scripts() {
  274. // Bump this when changes are made to bust cache
  275. $version = '20120110';
  276.  
  277. // Enqueue the global JS - Ajax will not work without it
  278. wp_enqueue_script( 'dtheme-ajax-js', get_template_directory_uri() . '/_inc/global.js', array( 'jquery' ), $version );
  279.  
  280. // Add words that we need to use in JS to the end of the page so they can be translated and still used.
  281. $params = array(
  282. 'my_favs' => __( 'My Favorites', 'buddypress' ),
  283. 'accepted' => __( 'Accepted', 'buddypress' ),
  284. 'rejected' => __( 'Rejected', 'buddypress' ),
  285. 'show_all_comments' => __( 'Show all comments for this thread', 'buddypress' ),
  286. 'show_all' => __( 'Show all', 'buddypress' ),
  287. 'comments' => __( 'comments', 'buddypress' ),
  288. 'close' => __( 'Close', 'buddypress' ),
  289. 'view' => __( 'View', 'buddypress' ),
  290. 'mark_as_fav' => __( 'Favorite', 'buddypress' ),
  291. 'remove_fav' => __( 'Remove Favorite', 'buddypress' )
  292. );
  293.  
  294. wp_localize_script( 'dtheme-ajax-js', 'BP_DTheme', $params );
  295. }
  296. add_action( 'wp_enqueue_scripts', 'bp_dtheme_enqueue_scripts' );
  297. endif;
  298.  
  299. if ( !function_exists( 'bp_dtheme_enqueue_styles' ) ) :
  300. /**
  301. * Enqueue theme CSS safely
  302. *
  303. * For maximum flexibility, BuddyPress Default's stylesheet is enqueued, using wp_enqueue_style().
  304. * If you're building a child theme of bp-default, your stylesheet will also be enqueued,
  305. * automatically, as dependent on bp-default's CSS. For this reason, bp-default child themes are
  306. * not recommended to include bp-default's stylesheet using @import.
  307. *
  308. * If you would prefer to use @import, or would like to change the way in which stylesheets are
  309. * enqueued, you can override bp_dtheme_enqueue_styles() in your theme's functions.php file.
  310. *
  311. * @see http://codex.wordpress.org/Function_Reference/wp_enqueue_style
  312. * @see http://codex.buddypress.org/releases/1-5-developer-and-designer-information/
  313. * @since 1.5
  314. */
  315. function bp_dtheme_enqueue_styles() {
  316.  
  317. // Bump this when changes are made to bust cache
  318. $version = '20120110';
  319.  
  320. // Register our main stylesheet
  321. wp_register_style( 'bp-default-main', get_template_directory_uri() . '/_inc/css/default.css', array(), $version );
  322.  
  323. // If the current theme is a child of bp-default, enqueue its stylesheet
  324. if ( is_child_theme() && 'bp-default' == get_template() ) {
  325. wp_enqueue_style( get_stylesheet(), get_stylesheet_uri(), array( 'bp-default-main' ), $version );
  326. }
  327.  
  328. // Enqueue the main stylesheet
  329. wp_enqueue_style( 'bp-default-main' );
  330.  
  331. // Default CSS RTL
  332. if ( is_rtl() )
  333. wp_enqueue_style( 'bp-default-main-rtl', get_template_directory_uri() . '/_inc/css/default-rtl.css', array( 'bp-default-main' ), $version );
  334.  
  335. // Responsive layout
  336. if ( current_theme_supports( 'bp-default-responsive' ) ) {
  337. wp_enqueue_style( 'bp-default-responsive', get_template_directory_uri() . '/_inc/css/responsive.css', array( 'bp-default-main' ), $version );
  338.  
  339. if ( is_rtl() )
  340. wp_enqueue_style( 'bp-default-responsive-rtl', get_template_directory_uri() . '/_inc/css/responsive-rtl.css', array( 'bp-default-responsive' ), $version );
  341. }
  342. }
  343. add_action( 'wp_enqueue_scripts', 'bp_dtheme_enqueue_styles' );
  344. endif;
  345.  
  346. if ( !function_exists( 'bp_dtheme_admin_header_style' ) ) :
  347. /**
  348. * Styles the header image displayed on the Appearance > Header admin panel.
  349. *
  350. * Referenced via add_custom_image_header() in bp_dtheme_setup().
  351. *
  352. * @since 1.2
  353. */
  354. function bp_dtheme_admin_header_style() {
  355. ?>
  356. <style type="text/css">
  357. #headimg {
  358. position: relative;
  359. color: #fff;
  360. background: url(<?php header_image() ?>);
  361. -moz-border-radius-bottomleft: 6px;
  362. -webkit-border-bottom-left-radius: 6px;
  363. -moz-border-radius-bottomright: 6px;
  364. -webkit-border-bottom-right-radius: 6px;
  365.  
  366. margin-bottom: 20px;
  367. height: 133px;
  368. }
  369.  
  370. #headimg h1{
  371. position: absolute;
  372. bottom: 15px;
  373. left: 15px;
  374. width: 44%;
  375. margin: 0;
  376. font-family: Arial, Tahoma, sans-serif;
  377. }
  378. #headimg h1 a{
  379. color:#<?php header_textcolor() ?>;
  380. text-decoration: none;
  381. border-bottom: none;
  382. }
  383. #headimg #desc{
  384. color:#<?php header_textcolor() ?>;
  385. font-size:1em;
  386. margin-top:-0.5em;
  387. }
  388.  
  389. #desc {
  390. display: none;
  391. }
  392.  
  393. <?php if ( 'blank' == get_header_textcolor() ) { ?>
  394. #headimg h1, #headimg #desc {
  395. display: none;
  396. }
  397. #headimg h1 a, #headimg #desc {
  398. color:#<?php echo HEADER_TEXTCOLOR ?>;
  399. }
  400. <?php } ?>
  401. </style>
  402. <?php
  403. }
  404. endif;
  405.  
  406. if ( !function_exists( 'bp_dtheme_custom_background_style' ) ) :
  407. /**
  408. * The style for the custom background image or colour.
  409. *
  410. * Referenced via add_custom_background() in bp_dtheme_setup().
  411. *
  412. * @see _custom_background_cb()
  413. * @since 1.5
  414. */
  415. function bp_dtheme_custom_background_style() {
  416. $background = get_background_image();
  417. $color = get_background_color();
  418. if ( ! $background && ! $color )
  419. return;
  420.  
  421. $style = $color ? "background-color: #$color;" : '';
  422.  
  423. if ( $style && !$background ) {
  424. $style .= ' background-image: none;';
  425.  
  426. } elseif ( $background ) {
  427. $image = " background-image: url('$background');";
  428.  
  429. $repeat = get_theme_mod( 'background_repeat', 'repeat' );
  430. if ( ! in_array( $repeat, array( 'no-repeat', 'repeat-x', 'repeat-y', 'repeat' ) ) )
  431. $repeat = 'repeat';
  432. $repeat = " background-repeat: $repeat;";
  433.  
  434. $position = get_theme_mod( 'background_position_x', 'left' );
  435. if ( ! in_array( $position, array( 'center', 'right', 'left' ) ) )
  436. $position = 'left';
  437. $position = " background-position: top $position;";
  438.  
  439. $attachment = get_theme_mod( 'background_attachment', 'scroll' );
  440. if ( ! in_array( $attachment, array( 'fixed', 'scroll' ) ) )
  441. $attachment = 'scroll';
  442. $attachment = " background-attachment: $attachment;";
  443.  
  444. $style .= $image . $repeat . $position . $attachment;
  445. }
  446. ?>
  447. <style type="text/css">
  448. body { <?php echo trim( $style ); ?> }
  449. </style>
  450. <?php
  451. }
  452. endif;
  453.  
  454. if ( !function_exists( 'bp_dtheme_header_style' ) ) :
  455. /**
  456. * The styles for the post thumbnails / custom page headers.
  457. *
  458. * Referenced via add_custom_image_header() in bp_dtheme_setup().
  459. *
  460. * @global WP_Query $post The current WP_Query object for the current post or page
  461. * @since 1.2
  462. */
  463. function bp_dtheme_header_style() {
  464. global $post;
  465.  
  466. $header_image = '';
  467.  
  468. if ( is_singular() && current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $post->ID ) ) {
  469. $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' );
  470.  
  471. // $src, $width, $height
  472. if ( !empty( $image ) && $image[1] >= HEADER_IMAGE_WIDTH )
  473. $header_image = $image[0];
  474.  
  475. } else {
  476. $header_image = get_header_image();
  477. }
  478. ?>
  479.  
  480. <style type="text/css">
  481. <?php if ( !empty( $header_image ) ) : ?>
  482. #header { background-image: url(<?php echo $header_image ?>); }
  483. <?php endif; ?>
  484.  
  485. <?php if ( 'blank' == get_header_textcolor() ) { ?>
  486. #header h1, #header #desc { display: none; }
  487. <?php } else { ?>
  488. #header h1 a, #desc { color:#<?php header_textcolor() ?>; }
  489. <?php } ?>
  490. </style>
  491.  
  492. <?php
  493. }
  494. endif;
  495.  
  496. if ( !function_exists( 'bp_dtheme_widgets_init' ) ) :
  497. /**
  498. * Register widgetised areas, including one sidebar and four widget-ready columns in the footer.
  499. *
  500. * To override bp_dtheme_widgets_init() in a child theme, remove the action hook and add your own
  501. * function tied to the init hook.
  502. *
  503. * @since 1.5
  504. */
  505. function bp_dtheme_widgets_init() {
  506. // Register the widget columns
  507. // Area 1, located in the sidebar. Empty by default.
  508. register_sidebar( array(
  509. 'name' => 'Sidebar',
  510. 'id' => 'sidebar-1',
  511. 'description' => __( 'The sidebar widget area', 'buddypress' ),
  512. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  513. 'after_widget' => '</div>',
  514. 'before_title' => '<h3 class="widgettitle">',
  515. 'after_title' => '</h3>'
  516. ) );
  517.  
  518. // Area 2, located in the footer. Empty by default.
  519. register_sidebar( array(
  520. 'name' => __( 'First Footer Widget Area', 'buddypress' ),
  521. 'id' => 'first-footer-widget-area',
  522. 'description' => __( 'The first footer widget area', 'buddypress' ),
  523. 'before_widget' => '<li id="%1$s" class="widget %2$s">',
  524. 'after_widget' => '</li>',
  525. 'before_title' => '<h3 class="widgettitle">',
  526. 'after_title' => '</h3>',
  527. ) );
  528.  
  529. // Area 3, located in the footer. Empty by default.
  530. register_sidebar( array(
  531. 'name' => __( 'Second Footer Widget Area', 'buddypress' ),
  532. 'id' => 'second-footer-widget-area',
  533. 'description' => __( 'The second footer widget area', 'buddypress' ),
  534. 'before_widget' => '<li id="%1$s" class="widget %2$s">',
  535. 'after_widget' => '</li>',
  536. 'before_title' => '<h3 class="widgettitle">',
  537. 'after_title' => '</h3>',
  538. ) );
  539.  
  540. // Area 4, located in the footer. Empty by default.
  541. register_sidebar( array(
  542. 'name' => __( 'Third Footer Widget Area', 'buddypress' ),
  543. 'id' => 'third-footer-widget-area',
  544. 'description' => __( 'The third footer widget area', 'buddypress' ),
  545. 'before_widget' => '<li id="%1$s" class="widget %2$s">',
  546. 'after_widget' => '</li>',
  547. 'before_title' => '<h3 class="widgettitle">',
  548. 'after_title' => '</h3>',
  549. ) );
  550.  
  551. // Area 5, located in the footer. Empty by default.
  552. register_sidebar( array(
  553. 'name' => __( 'Fourth Footer Widget Area', 'buddypress' ),
  554. 'id' => 'fourth-footer-widget-area',
  555. 'description' => __( 'The fourth footer widget area', 'buddypress' ),
  556. 'before_widget' => '<li id="%1$s" class="widget %2$s">',
  557. 'after_widget' => '</li>',
  558. 'before_title' => '<h3 class="widgettitle">',
  559. 'after_title' => '</h3>',
  560. ) );
  561. }
  562. add_action( 'widgets_init', 'bp_dtheme_widgets_init' );
  563. endif;
  564.  
  565. if ( !function_exists( 'bp_dtheme_blog_comments' ) ) :
  566. /**
  567. * Template for comments and pingbacks.
  568. *
  569. * To override this walker in a child theme without modifying the comments template
  570. * simply create your own bp_dtheme_blog_comments(), and that function will be used instead.
  571. *
  572. * Used as a callback by wp_list_comments() for displaying the comments.
  573. *
  574. * @param mixed $comment Comment record from database
  575. * @param array $args Arguments from wp_list_comments() call
  576. * @param int $depth Comment nesting level
  577. * @see wp_list_comments()
  578. * @since 1.2
  579. */
  580. function bp_dtheme_blog_comments( $comment, $args, $depth ) {
  581. $GLOBALS['comment'] = $comment;
  582.  
  583. if ( 'pingback' == $comment->comment_type )
  584. return false;
  585.  
  586. if ( 1 == $depth )
  587. $avatar_size = 50;
  588. else
  589. $avatar_size = 25;
  590. ?>
  591.  
  592. <li <?php comment_class() ?> id="comment-<?php comment_ID() ?>">
  593. <div class="comment-avatar-box">
  594. <div class="avb">
  595. <a href="<?php echo get_comment_author_url() ?>" rel="nofollow">
  596. <?php if ( $comment->user_id ) : ?>
  597. <?php echo bp_core_fetch_avatar( array( 'item_id' => $comment->user_id, 'width' => $avatar_size, 'height' => $avatar_size, 'email' => $comment->comment_author_email ) ) ?>
  598. <?php else : ?>
  599. <?php echo get_avatar( $comment, $avatar_size ) ?>
  600. <?php endif; ?>
  601. </a>
  602. </div>
  603. </div>
  604.  
  605. <div class="comment-content">
  606. <div class="comment-meta">
  607. <p>
  608. <?php
  609. /* translators: 1: comment author url, 2: comment author name, 3: comment permalink, 4: comment date/timestamp*/
  610. printf( __( '<a href="%1$s" rel="nofollow">%2$s</a> said on <a href="%3$s"><span class="time-since">%4$s</span></a>', 'buddypress' ), get_comment_author_url(), get_comment_author(), get_comment_link(), get_comment_date() );
  611. ?>
  612. </p>
  613. </div>
  614.  
  615. <div class="comment-entry">
  616. <?php if ( $comment->comment_approved == '0' ) : ?>
  617. <em class="moderate"><?php _e( 'Your comment is awaiting moderation.', 'buddypress' ); ?></em>
  618. <?php endif; ?>
  619.  
  620. <?php comment_text() ?>
  621. </div>
  622.  
  623. <div class="comment-options">
  624. <?php if ( comments_open() ) : ?>
  625. <?php comment_reply_link( array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ); ?>
  626. <?php endif; ?>
  627.  
  628. <?php if ( current_user_can( 'edit_comment', $comment->comment_ID ) ) : ?>
  629. <?php printf( '<a class="button comment-edit-link bp-secondary-action" href="%1$s" title="%2$s">%3$s</a> ', get_edit_comment_link( $comment->comment_ID ), esc_attr__( 'Edit comment', 'buddypress' ), __( 'Edit', 'buddypress' ) ) ?>
  630. <?php endif; ?>
  631.  
  632. </div>
  633.  
  634. </div>
  635.  
  636. <?php
  637. }
  638. endif;
  639.  
  640. if ( !function_exists( 'bp_dtheme_page_on_front' ) ) :
  641. /**
  642. * Return the ID of a page set as the home page.
  643. *
  644. * @return false|int ID of page set as the home page
  645. * @since 1.2
  646. */
  647. function bp_dtheme_page_on_front() {
  648. if ( 'page' != get_option( 'show_on_front' ) )
  649. return false;
  650.  
  651. return apply_filters( 'bp_dtheme_page_on_front', get_option( 'page_on_front' ) );
  652. }
  653. endif;
  654.  
  655. if ( !function_exists( 'bp_dtheme_activity_secondary_avatars' ) ) :
  656. /**
  657. * Add secondary avatar image to this activity stream's record, if supported.
  658. *
  659. * @param string $action The text of this activity
  660. * @param BP_Activity_Activity $activity Activity object
  661. * @package BuddyPress Theme
  662. * @return string
  663. * @since 1.2.6
  664. */
  665. function bp_dtheme_activity_secondary_avatars( $action, $activity ) {
  666. switch ( $activity->component ) {
  667. case 'groups' :
  668. case 'friends' :
  669. // Only insert avatar if one exists
  670. if ( $secondary_avatar = bp_get_activity_secondary_avatar() ) {
  671. $reverse_content = strrev( $action );
  672. $position = strpos( $reverse_content, 'a<' );
  673. $action = substr_replace( $action, $secondary_avatar, -$position - 2, 0 );
  674. }
  675. break;
  676. }
  677.  
  678. return $action;
  679. }
  680. add_filter( 'bp_get_activity_action_pre_meta', 'bp_dtheme_activity_secondary_avatars', 10, 2 );
  681. endif;
  682.  
  683. if ( !function_exists( 'bp_dtheme_show_notice' ) ) :
  684. /**
  685. * Show a notice when the theme is activated - workaround by Ozh (http://old.nabble.com/Activation-hook-exist-for-themes--td25211004.html)
  686. *
  687. * @since 1.2
  688. */
  689. function bp_dtheme_show_notice() {
  690. global $pagenow;
  691.  
  692. // Bail if bp-default theme was not just activated
  693. if ( empty( $_GET['activated'] ) || ( 'themes.php' != $pagenow ) || !is_admin() )
  694. return;
  695.  
  696. ?>
  697.  
  698. <div id="message" class="updated fade">
  699. <p><?php printf( __( 'Theme activated! This theme contains <a href="%s">custom header image</a> support and <a href="%s">sidebar widgets</a>.', 'buddypress' ), admin_url( 'themes.php?page=custom-header' ), admin_url( 'widgets.php' ) ) ?></p>
  700. </div>
  701.  
  702. <style type="text/css">#message2, #message0 { display: none; }</style>
  703.  
  704. <?php
  705. }
  706. add_action( 'admin_notices', 'bp_dtheme_show_notice' );
  707. endif;
  708.  
  709. if ( !function_exists( 'bp_dtheme_main_nav' ) ) :
  710. /**
  711. * wp_nav_menu() callback from the main navigation in header.php
  712. *
  713. * Used when the custom menus haven't been configured.
  714. *
  715. * @global object $bp Global BuddyPress settings object
  716. * @param array Menu arguments from wp_nav_menu()
  717. * @see wp_nav_menu()
  718. * @since 1.5
  719. */
  720. function bp_dtheme_main_nav( $args ) {
  721. global $bp;
  722.  
  723. $pages_args = array(
  724. 'depth' => 0,
  725. 'echo' => false,
  726. 'exclude' => '',
  727. 'title_li' => ''
  728. );
  729. $menu = wp_page_menu( $pages_args );
  730. $menu = str_replace( array( '<div class="menu"><ul>', '</ul></div>' ), array( '<ul id="nav">', '</ul><!-- #nav -->' ), $menu );
  731. echo $menu;
  732.  
  733. do_action( 'bp_nav_items' );
  734. }
  735. endif;
  736.  
  737. if ( !function_exists( 'bp_dtheme_page_menu_args' ) ) :
  738. /**
  739. * Get our wp_nav_menu() fallback, bp_dtheme_main_nav(), to show a home link.
  740. *
  741. * @param array $args Default values for wp_page_menu()
  742. * @see wp_page_menu()
  743. * @since 1.5
  744. */
  745. function bp_dtheme_page_menu_args( $args ) {
  746. $args['show_home'] = true;
  747. return $args;
  748. }
  749. add_filter( 'wp_page_menu_args', 'bp_dtheme_page_menu_args' );
  750. endif;
  751.  
  752. if ( !function_exists( 'bp_dtheme_comment_form' ) ) :
  753. /**
  754. * Applies BuddyPress customisations to the post comment form.
  755. *
  756. * @global string $user_identity The display name of the user
  757. * @param array $default_labels The default options for strings, fields etc in the form
  758. * @see comment_form()
  759. * @since 1.5
  760. */
  761. function bp_dtheme_comment_form( $default_labels ) {
  762. global $user_identity;
  763.  
  764. $commenter = wp_get_current_commenter();
  765. $req = get_option( 'require_name_email' );
  766. $aria_req = ( $req ? " aria-required='true'" : '' );
  767. $fields = array(
  768. 'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name', 'buddypress' ) . ( $req ? '<span class="required"> *</span>' : '' ) . '</label> ' .
  769. '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
  770. 'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email', 'buddypress' ) . ( $req ? '<span class="required"> *</span>' : '' ) . '</label> ' .
  771. '<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
  772. 'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website', 'buddypress' ) . '</label>' .
  773. '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>',
  774. );
  775.  
  776. $new_labels = array(
  777. 'comment_field' => '<p class="form-textarea"><textarea name="comment" id="comment" cols="60" rows="10" aria-required="true">
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement