Advertisement
Guest User

profile-link-custom-community-functions.php

a guest
Jun 16th, 2012
636
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.87 KB | None | 0 0
  1. <?php
  2.  
  3. require_once( dirname(__FILE__) . '/admin/cheezcap.php');
  4. require_once( dirname(__FILE__) . '/core/loader.php');
  5.  
  6. /** Tell WordPress to run cc_setup() when the 'after_setup_theme' hook is run. */
  7. add_action( 'after_setup_theme', 'cc_setup' );
  8. if ( ! function_exists( 'cc_setup' ) ):
  9. /**
  10. * Sets up theme defaults and registers support for various WordPress features.
  11. *
  12. * To override cc_setup() in a child theme, add your own cc_setup to your child theme's
  13. * functions.php file.
  14. *
  15. * @uses add_theme_support() To add support for post thumbnails and automatic feed links.
  16. * @uses register_nav_menus() To add support for navigation menus.
  17. * @uses add_custom_background() To add support for a custom background.
  18. * @uses add_editor_style() To style the visual editor.
  19. * @uses load_theme_textdomain() For translation/localization support.
  20. * @uses add_custom_image_header() To add support for a custom header.
  21. * @uses register_default_headers() To register the default custom header images provided with the theme.
  22. * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
  23. * @uses $content_width To set a content width according to the sidebars.
  24. * @uses BP_DISABLE_ADMIN_BAR To disable the admin bar if set to disabled in the themesettings.
  25. *
  26. */
  27. function cc_setup() {
  28. global $cap, $content_width;
  29.  
  30. // This theme styles the visual editor with editor-style.css to match the theme style.
  31. add_editor_style();
  32.  
  33. // This theme uses post thumbnails
  34. if ( function_exists( 'add_theme_support' ) ) {
  35. add_theme_support( 'post-thumbnails' );
  36. set_post_thumbnail_size( 222, 160, true );
  37. add_image_size( 'slider-top-large', 1006, 250, true );
  38. add_image_size( 'slider-large', 990, 250, true );
  39. add_image_size( 'slider-middle', 756, 250, true );
  40. add_image_size( 'slider-thumbnail', 80, 50, true );
  41. add_image_size( 'post-thumbnails', 222, 160, true );
  42. add_image_size( 'single-post-thumbnail', 598, 372, true );
  43. }
  44.  
  45. // Add default posts and comments RSS feed links to head
  46. add_theme_support( 'automatic-feed-links' );
  47.  
  48. // Make theme available for translation
  49. // Translations can be filed in the /languages/ directory
  50. load_theme_textdomain( 'cc', TEMPLATEPATH . '/languages' );
  51.  
  52. $locale = get_locale();
  53. $locale_file = TEMPLATEPATH . "/languages/$locale.php";
  54. if ( is_readable( $locale_file ) )
  55. require_once( $locale_file );
  56.  
  57. // This theme uses wp_nav_menu() in one location.
  58. register_nav_menus( array(
  59. 'menu_top' => __( 'Header top menu', 'cc' ),
  60. 'primary' => __( 'Header bottom menu', 'cc' ),
  61. ) );
  62.  
  63. // This theme allows users to set a custom background
  64. if($cap->add_custom_background == true){
  65. add_custom_background();
  66. }
  67. // Your changeable header business starts here
  68. define( 'HEADER_TEXTCOLOR', '888888' );
  69.  
  70. // No CSS, just an IMG call. The %s is a placeholder for the theme template directory URI.
  71. define( 'HEADER_IMAGE', '%s/images/default-header.png' );
  72.  
  73. // The height and width of your custom header. You can hook into the theme's own filters to change these values.
  74. // Add a filter to cc_header_image_width and cc_header_image_height to change these values.
  75. define( 'HEADER_IMAGE_WIDTH', apply_filters( 'cc_header_image_width', 1000 ) );
  76. define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'cc_header_image_height', 233 ) );
  77.  
  78.  
  79. // Add a way for the custom header to be styled in the admin panel that controls
  80. // custom headers. See cc_admin_header_style(), below.
  81. if($cap->add_custom_image_header == true){
  82. add_custom_image_header( 'cc_header_style', 'cc_admin_header_style', 'cc_admin_header_image' );
  83. }
  84.  
  85. // Define Content with
  86. $content_width = "670";
  87. if($cap->sidebar_position == "left and right"){
  88. $content_width = "432";
  89. }
  90.  
  91. // Define disable the admin bar
  92. if($cap->bp_login_bar_top == 'off') {
  93. define( 'BP_DISABLE_ADMIN_BAR', true );
  94. }
  95.  
  96. }
  97. endif;
  98.  
  99. if ( ! function_exists( 'cc_header_style' ) ) :
  100. /**
  101. * Styles the header image and text displayed on the blog
  102. *
  103. */
  104. function cc_header_style() {
  105. // If no custom options for text are set, let's bail
  106. // get_header_textcolor() options: HEADER_TEXTCOLOR is default, hide text (returns 'blank') or any hex value
  107. if ( HEADER_TEXTCOLOR == get_header_textcolor() )
  108. return;
  109. // If we get this far, we have custom styles. Let's do this.
  110. ?>
  111. <style type="text/css">
  112. <?php
  113. // Has the text been hidden?
  114. if ( 'blank' == get_header_textcolor() ) :
  115. ?>
  116. #blog-description, #header div#logo h1 a, #header div#logo h4 a {
  117. position: absolute;
  118. left: -9000px;
  119. }
  120. <?php
  121. // If the user has set a custom color for the text use that
  122. else :
  123. ?>
  124. #blog-description, #header div#logo h1 a, #header div#logo h4 a {
  125. color: #555555;
  126. color: #<?php echo get_header_textcolor(); ?> !important;
  127. }
  128. <?php endif; ?>
  129. </style>
  130. <?php
  131. }
  132. endif;
  133.  
  134.  
  135. if ( ! function_exists( 'cc_admin_header_style' ) ) :
  136. /**
  137. * Styles the header image displayed on the Appearance > Header admin panel.
  138. *
  139. * Referenced via add_custom_image_header() in cc_setup().
  140. *
  141. */
  142. function cc_admin_header_style() {
  143. ?>
  144. <style type="text/css">
  145. .appearance_page_custom-header #headimg {
  146. background: #<?php echo get_background_color(); ?>;
  147. border: none;
  148. text-align: center;
  149. }
  150. #headimg h1,
  151. #desc {
  152. font-family: "Helvetica Neue", Arial, Helvetica, "Nimbus Sans L", sans-serif;
  153. }
  154. #headimg h1 {
  155. margin: 0;
  156. }
  157. #headimg h1 a {
  158. font-size: 36px;
  159. letter-spacing: -0.03em;
  160. line-height: 42px;
  161. text-decoration: none;
  162. }
  163. #desc {
  164. font-size: 18px;
  165. line-height: 31px;
  166. padding: 0 0 9px 0;
  167. }
  168. <?php
  169. // If the user has set a custom color for the text use that
  170. if ( get_header_textcolor() != HEADER_TEXTCOLOR ) :
  171. ?>
  172. #site-title a,
  173. #site-description {
  174. color: #<?php echo get_header_textcolor(); ?>;
  175. }
  176. <?php endif; ?>
  177. #headimg img {
  178. max-width: 990px;
  179. width: 100%;
  180. }
  181. </style>
  182. <?php
  183. }
  184. endif;
  185.  
  186. if ( ! function_exists( 'cc_admin_header_image' ) ) :
  187. /**
  188. * Custom header image markup displayed on the Appearance > Header admin panel.
  189. *
  190. * Referenced via add_custom_image_header() in cc_setup().
  191. *
  192. */
  193. function cc_admin_header_image() { ?>
  194. <div id="headimg">
  195. <?php
  196. if ( 'blank' == get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) || '' == get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) )
  197. $style = ' style="display:none;"';
  198. else
  199. $style = ' style="color:#' . get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) . ';"';
  200. ?>
  201. <h1><a id="name"<?php echo $style; ?> onclick="return false;" href="<?php echo home_url( '/' ); ?>"><?php bloginfo( 'name' ); ?></a></h1>
  202. <div id="desc"<?php echo $style; ?>><?php bloginfo( 'description' ); ?></div>
  203. <img src="<?php esc_url ( header_image() ); ?>" alt="" />
  204. </div>
  205. <?php }
  206. endif;
  207.  
  208. add_filter('widget_text', 'do_shortcode');
  209. add_action( 'widgets_init', 'cc_widgets_init' );
  210. function cc_widgets_init(){
  211. register_sidebars( 1,
  212. array(
  213. 'name' => 'sidebar right',
  214. 'id' => 'sidebar',
  215. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  216. 'after_widget' => '</div><div class="clear"></div>',
  217. 'before_title' => '<h3 class="widgettitle">',
  218. 'after_title' => '</h3>'
  219. )
  220. );
  221. register_sidebars( 1,
  222. array(
  223. 'name' => 'sidebar left',
  224. 'id' => 'leftsidebar',
  225. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  226. 'after_widget' => '</div><div class="clear"></div>',
  227. 'before_title' => '<h3 class="widgettitle">',
  228. 'after_title' => '</h3>'
  229. )
  230. );
  231. ### Add Sidebars
  232. register_sidebars( 1,
  233. array(
  234. 'name' => 'header full width',
  235. 'id' => 'headerfullwidth',
  236. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  237. 'after_widget' => '</div><div class="clear"></div>',
  238. 'before_title' => '<h3 class="widgettitle">',
  239. 'after_title' => '</h3>'
  240. )
  241. );
  242. register_sidebars( 1,
  243. array(
  244. 'name' => 'header left',
  245. 'id' => 'headerleft',
  246. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  247. 'after_widget' => '</div><div class="clear"></div>',
  248. 'before_title' => '<h3 class="widgettitle">',
  249. 'after_title' => '</h3>'
  250. )
  251. );
  252. register_sidebars( 1,
  253. array(
  254. 'name' => 'header center',
  255. 'id' => 'headercenter',
  256. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  257. 'after_widget' => '</div><div class="clear"></div>',
  258. 'before_title' => '<h3 class="widgettitle">',
  259. 'after_title' => '</h3>'
  260. )
  261. );
  262. register_sidebars( 1,
  263. array(
  264. 'name' => 'header right',
  265. 'id' => 'headerright',
  266. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  267. 'after_widget' => '</div><div class="clear"></div>',
  268. 'before_title' => '<h3 class="widgettitle">',
  269. 'after_title' => '</h3>'
  270. )
  271. );
  272. register_sidebars( 1,
  273. array(
  274. 'name' => 'footer full width',
  275. 'id' => 'footerfullwidth',
  276. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  277. 'after_widget' => '</div><div class="clear"></div>',
  278. 'before_title' => '<h3 class="widgettitle">',
  279. 'after_title' => '</h3>'
  280. )
  281. );
  282. register_sidebars( 1,
  283. array(
  284. 'name' => 'footer left',
  285. 'id' => 'footerleft',
  286. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  287. 'after_widget' => '</div><div class="clear"></div>',
  288. 'before_title' => '<h3 class="widgettitle">',
  289. 'after_title' => '</h3>'
  290. )
  291. );
  292. register_sidebars( 1,
  293. array(
  294. 'name' => 'footer center',
  295. 'id' => 'footercenter',
  296. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  297. 'after_widget' => '</div><div class="clear"></div>',
  298. 'before_title' => '<h3 class="widgettitle">',
  299. 'after_title' => '</h3>'
  300. )
  301. );
  302. register_sidebars( 1,
  303. array(
  304. 'name' => 'footer right',
  305. 'id' => 'footerright',
  306. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  307. 'after_widget' => '</div><div class="clear"></div>',
  308. 'before_title' => '<h3 class="widgettitle">',
  309. 'after_title' => '</h3>'
  310. )
  311. );
  312. register_sidebars( 1,
  313. array(
  314. 'name' => 'member header',
  315. 'id' => 'memberheader',
  316. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  317. 'after_widget' => '</div><div class="clear"></div>',
  318. 'before_title' => '<h3 class="widgettitle">',
  319. 'after_title' => '</h3>'
  320. )
  321. );
  322. register_sidebars( 1,
  323. array(
  324. 'name' => 'member header left',
  325. 'id' => 'memberheaderleft',
  326. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  327. 'after_widget' => '</div><div class="clear"></div>',
  328. 'before_title' => '<h3 class="widgettitle">',
  329. 'after_title' => '</h3>'
  330. )
  331. );
  332. register_sidebars( 1,
  333. array(
  334. 'name' => 'member header center',
  335. 'id' => 'memberheadercenter',
  336. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  337. 'after_widget' => '</div><div class="clear"></div>',
  338. 'before_title' => '<h3 class="widgettitle">',
  339. 'after_title' => '</h3>'
  340. )
  341. );
  342. register_sidebars( 1,
  343. array(
  344. 'name' => 'member header right',
  345. 'id' => 'memberheaderright',
  346. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  347. 'after_widget' => '</div><div class="clear"></div>',
  348. 'before_title' => '<h3 class="widgettitle">',
  349. 'after_title' => '</h3>'
  350. )
  351. );
  352. register_sidebars( 1,
  353. array(
  354. 'name' => 'member sidebar left',
  355. 'id' => 'membersidebarleft',
  356. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  357. 'after_widget' => '</div><div class="clear"></div>',
  358. 'before_title' => '<h3 class="widgettitle">',
  359. 'after_title' => '</h3>'
  360. )
  361. );
  362. register_sidebars( 1,
  363. array(
  364. 'name' => 'member sidebar right',
  365. 'id' => 'membersidebarright',
  366. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  367. 'after_widget' => '</div><div class="clear"></div>',
  368. 'before_title' => '<h3 class="widgettitle">',
  369. 'after_title' => '</h3>'
  370. )
  371. );
  372. register_sidebars( 1,
  373. array(
  374. 'name' => 'group header',
  375. 'id' => 'groupheader',
  376. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  377. 'after_widget' => '</div><div class="clear"></div>',
  378. 'before_title' => '<h3 class="widgettitle">',
  379. 'after_title' => '</h3>'
  380. )
  381. );
  382. register_sidebars( 1,
  383. array(
  384. 'name' => 'group header left',
  385. 'id' => 'groupheaderleft',
  386. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  387. 'after_widget' => '</div><div class="clear"></div>',
  388. 'before_title' => '<h3 class="widgettitle">',
  389. 'after_title' => '</h3>'
  390. )
  391. );
  392. register_sidebars( 1,
  393. array(
  394. 'name' => 'group header center',
  395. 'id' => 'groupheadercenter',
  396. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  397. 'after_widget' => '</div><div class="clear"></div>',
  398. 'before_title' => '<h3 class="widgettitle">',
  399. 'after_title' => '</h3>'
  400. )
  401. );
  402. register_sidebars( 1,
  403. array(
  404. 'name' => 'group header right',
  405. 'id' => 'groupheaderright',
  406. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  407. 'after_widget' => '</div><div class="clear"></div>',
  408. 'before_title' => '<h3 class="widgettitle">',
  409. 'after_title' => '</h3>'
  410. )
  411. );
  412. register_sidebars( 1,
  413. array(
  414. 'name' => 'group sidebar left',
  415. 'id' => 'groupsidebarleft',
  416. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  417. 'after_widget' => '</div><div class="clear"></div>',
  418. 'before_title' => '<h3 class="widgettitle">',
  419. 'after_title' => '</h3>'
  420. )
  421. );
  422. register_sidebars( 1,
  423. array(
  424. 'name' => 'group sidebar right',
  425. 'id' => 'groupsidebarright',
  426. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  427. 'after_widget' => '</div><div class="clear"></div>',
  428. 'before_title' => '<h3 class="widgettitle">',
  429. 'after_title' => '</h3>'
  430. )
  431. );
  432. register_sidebars( 15,
  433. array(
  434. 'name' => 'shortcode %1$s',
  435. 'id' => 'shortcode',
  436. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  437. 'after_widget' => '</div><div class="clear"></div>',
  438. 'before_title' => '<h3 class="widgettitle">',
  439. 'after_title' => '</h3>'
  440. )
  441. );
  442.  
  443. }
  444. if($cap->buddydev_search == true && defined('BP_VERSION') && function_exists('bp_is_active')) {
  445.  
  446. //* Add these code to your functions.php to allow Single Search page for all buddypress components*/
  447. // Remove Buddypress search drowpdown for selecting members etc
  448. add_filter("bp_search_form_type_select", "cc_remove_search_dropdown" );
  449. function cc_remove_search_dropdown($select_html){
  450. return '';
  451. }
  452.  
  453. remove_action( 'init', 'bp_core_action_search_site', 5 );//force buddypress to not process the search/redirect
  454. add_action( 'init', 'cc_bp_buddydev_search', 10 );// custom handler for the search
  455.  
  456. function cc_bp_buddydev_search(){
  457. global $bp;
  458. if ( $bp->current_component == BP_SEARCH_SLUG )//if thids is search page
  459. bp_core_load_template( apply_filters( 'bp_core_template_search_template', 'search-single' ) );//load the single searh template
  460. }
  461. add_action("advance-search","cc_show_search_results",1);//highest priority
  462.  
  463. /* we just need to filter the query and change search_term=The search text*/
  464. function cc_show_search_results(){
  465. //filter the ajaxquerystring
  466. add_filter("bp_ajax_querystring","cc_global_search_qs",100,2);
  467. }
  468.  
  469. //show the search results for member*/
  470. function cc_show_member_search(){
  471. ?>
  472. <div class="memberss-search-result search-result">
  473. <h2 class="content-title"><?php _e("Members Results","cc");?></h2>
  474. <?php locate_template( array( 'members/members-loop.php' ), true ) ; ?>
  475. <?php global $members_template;
  476. if($members_template->total_member_count>1):?>
  477. <a href="<?php echo bp_get_root_domain().'/'.BP_MEMBERS_SLUG.'/?s='.$_REQUEST['search-terms']?>" ><?php _e(sprintf("View all %d matched Members",$members_template->total_member_count),"cc");?></a>
  478. <?php endif; ?>
  479. </div>
  480. <?php
  481. }
  482.  
  483. //Hook Member results to search page
  484. add_action("advance-search","cc_show_member_search",10); //the priority defines where in page this result will show up(the order of member search in other searchs)
  485. function cc_show_groups_search(){
  486. ?>
  487. <div class="groups-search-result search-result">
  488. <h2 class="content-title"><?php _e("Group Search","cc");?></h2>
  489. <?php locate_template( array('groups/groups-loop.php' ), true ) ; ?>
  490.  
  491. <a href="<?php echo bp_get_root_domain().'/'.BP_GROUPS_SLUG.'/?s='.$_REQUEST['search-terms']?>" ><?php _e("View All matched Groups","cc");?></a>
  492. </div>
  493. <?php
  494. //endif;
  495. }
  496.  
  497. //Hook Groups results to search page
  498. if(bp_is_active( 'groups' ))
  499. add_action("advance-search","cc_show_groups_search",10);
  500.  
  501. /**
  502. *
  503. * Show blog posts in search
  504. */
  505. function cc_show_site_blog_search(){
  506. ?>
  507. <div class="blog-search-result search-result">
  508.  
  509. <h2 class="content-title"><?php _e("Blog Search","cc");?></h2>
  510.  
  511. <?php locate_template( array( 'search-loop.php' ), true ) ; ?>
  512. <a href="<?php echo bp_get_root_domain().'/?s='.$_REQUEST['search-terms']?>" ><?php _e("View All matched Posts","cc");?></a>
  513. </div>
  514. <?php
  515. }
  516.  
  517. //Hook Blog Post results to search page
  518. add_action("advance-search","cc_show_site_blog_search",10);
  519.  
  520. //show forums search
  521. function cc_show_forums_search(){
  522. ?>
  523. <div class="forums-search-result search-result">
  524. <h2 class="content-title"><?php _e("Forums Search","cc");?></h2>
  525. <?php locate_template( array( 'forums/forums-loop.php' ), true ) ; ?>
  526. <a href="<?php echo bp_get_root_domain().'/'.BP_FORUMS_SLUG.'/?s='.$_REQUEST['search-terms']?>" ><?php _e("View All matched forum posts","cc");?></a>
  527. </div>
  528. <?php
  529. }
  530.  
  531. //Hook Forums results to search page
  532. if ( bp_is_active( 'forums' ) && bp_is_active( 'groups' ) && ( function_exists( 'bp_forums_is_installed_correctly' )))
  533. add_action("advance-search","cc_show_forums_search",20);
  534.  
  535.  
  536. //show blogs search result
  537.  
  538. function cc_show_blogs_search(){
  539.  
  540. if(!is_multisite())
  541. return;
  542.  
  543. ?>
  544. <div class="blogs-search-result search-result">
  545. <h2 class="content-title"><?php _e("Blogs Search","cc");?></h2>
  546. <?php locate_template( array( 'blogs/blogs-loop.php' ), true ) ; ?>
  547. <a href="<?php echo bp_get_root_domain().'/'.BP_BLOGS_SLUG.'/?s='.$_REQUEST['search-terms']?>" ><?php _e("View All matched Blogs","cc");?></a>
  548. </div>
  549. <?php
  550. }
  551.  
  552. //Hook Blogs results to search page if blogs comonent is active
  553. if(bp_is_active( 'blogs' ))
  554. add_action("advance-search","cc_show_blogs_search",10);
  555.  
  556.  
  557. //modify the query string with the search term
  558. function cc_global_search_qs(){
  559. if(empty($_REQUEST['search-terms']))
  560. return;
  561.  
  562. return "search_terms=".$_REQUEST['search-terms'];
  563. }
  564.  
  565. function cc_is_advance_search(){
  566. global $bp;
  567. if($bp->current_component == BP_SEARCH_SLUG)
  568. return true;
  569. return false;
  570. }
  571. remove_action( 'bp_init', 'bp_core_action_search_site', 7 );
  572.  
  573. }
  574.  
  575. // Filter wp_nav_menu() to add profile link
  576.  
  577. add_filter( 'wp_nav_menu_items', 'mme_nav_menu_profile_link' );
  578. function mme_nav_menu_profile_link($menu) {
  579. if (!is_user_logged_in())
  580. return $menu;
  581. else
  582. $profilelink = '<li><a href="' . bp_loggedin_user_domain( '/' ) . '">' . __('My Profile', 'buddypress' ) . '</a></li>';
  583. $menu = $menu . $profilelink;
  584. return $menu;
  585. }
  586. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement