timfurnish

theme-generator.php

Feb 18th, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 27.22 KB | None | 0 0
  1. <?php
  2. class CC_Theme_Generator{
  3.  
  4.     var $detect;
  5.  
  6.     /**
  7.      * PHP 4 constructor
  8.      *
  9.      * @package custom community
  10.      * @since 1.8.3
  11.      */
  12.     function custom_community() {
  13.         $this->__construct();
  14.     }
  15.  
  16.     /**
  17.      * PHP 5 constructor
  18.      *
  19.      * @package Custom Community
  20.      * @since 1.8.3
  21.      */
  22.     function __construct() {
  23.         global $bp;
  24.        
  25.         $this->detect = new TK_WP_Detect();
  26.    
  27.         // load predefined constants first
  28.         add_action( 'bp_head', array( $this, 'load_constants' ), 2 );
  29.        
  30.         //CC_Theme_Generator::load_constants();
  31.        
  32.         // header.php
  33.         add_action( 'bp_before_header', array( $this, 'innerrim_before_header' ), 2 );
  34.         add_action( 'bp_after_header', array( $this, 'innerrim_after_header' ), 2 );
  35.         add_action( 'bp_before_access', array( $this, 'menue_enable_search' ), 2 );
  36.         add_action( 'bp_before_access', array( $this, 'header_logo' ), 2 );
  37.         add_action( 'bp_menu', array( $this, 'bp_menu' ), 2 );
  38.         add_filter( 'wp_page_menu_args', array( $this, 'remove_home_nav_from_fallback'), 100 );
  39.         add_action( 'bp_after_header', array( $this, 'slideshow_home' ), 2 );
  40.         add_action( 'favicon', array( $this, 'favicon' ), 2 );
  41.        
  42.         // footer.php
  43.         add_action( 'bp_before_footer', array( $this, 'innerrim_before_footer' ), 2 );
  44.         add_action( 'bp_after_footer', array( $this, 'innerrim_after_footer' ), 2 );
  45.         add_action( 'bp_footer', array( $this, 'footer_content' ), 2 );
  46.        
  47.         // sidebars
  48.         add_action( 'sidebar_left', array( $this, 'sidebar_left' ), 2 );
  49.         add_action( 'sidebar_right', array( $this, 'sidebar_right' ), 2 );
  50.         add_action( 'bp_inside_after_sidebar', array( $this, 'login_sidebar_widget' ), 2 );
  51.        
  52.         // home
  53.         add_action( 'bp_before_blog_home', array( $this, 'default_homepage_last_posts' ), 2 );
  54.         add_filter('body_class',array( $this, 'home_body_class'), 10 );
  55.        
  56.         // helper functions
  57.         add_action( 'blog_post_entry', array( $this, 'excerpt_on' ), 2 );
  58.        
  59.         // groups
  60.         add_action( 'bp_before_group_home_content', array( $this, 'before_group_home_content' ), 2 );
  61.        
  62.         // profile
  63.         add_action( 'bp_before_member_home_content', array( $this, 'before_member_home_content' ), 2 );
  64.        
  65.         // custom login
  66.         add_action('login_head', array( $this, 'custom_login'), 2 );
  67.        
  68.        
  69.     }
  70.    
  71.  
  72.     function load_constants(){
  73.         global $cap, $post;
  74.  
  75.         $component = explode('-',$this->detect->tk_get_page_type());
  76.        
  77.         if($cap->sidebar_position == ''){
  78.             $cap->sidebar_position = 'right';
  79.             $cap->menue_disable_home = true;
  80.             $cap->enable_slideshow_home = 'home';
  81.             $cap->header_text = 'off';
  82.             $cap->preview = true;
  83.         }  
  84.        
  85.         $sidebar_position = $cap->sidebar_position;
  86.        
  87.         if(!empty($component[2])){
  88.             if($component[2] == 'groups' && !empty($component[3]) && $cap->bp_groups_sidebars != 'default') {
  89.                 $sidebar_position = $cap->bp_groups_sidebars;
  90.             } elseif($component[2] == 'profile' && !empty($component[3]) && $cap->bp_profile_sidebars != 'default') {
  91.                 $sidebar_position = $cap->bp_profile_sidebars;
  92.             }
  93.         }
  94.            
  95.         $leftsidebar_width = $cap->leftsidebar_width;
  96.         $rightsidebar_width = $cap->rightsidebar_width;
  97.        
  98.         switch ($sidebar_position) {
  99.             case 'left': $cap->rightsidebar_width = 0; break;
  100.             case 'right': $cap->leftsidebar_width = 0; break;
  101.             case 'none': $cap->leftsidebar_width = 0; $cap->rightsidebar_width = 0; break;
  102.             case 'full-width': $cap->leftsidebar_width = 0; $cap->rightsidebar_width = 0; break;
  103.             case 'full-width-venue': $cap->leftsidebar_width = 0; $cap->rightsidebar_width = 0; break;
  104.         }
  105.        
  106.         $tmp = get_post_meta( $post->ID, '_wp_page_template', true );
  107.        
  108.         switch ($tmp) {
  109.             case 'left-sidebar.php': $cap->leftsidebar_width = $leftsidebar_width; $cap->rightsidebar_width = 0; break;
  110.             case 'right-sidebar.php': $cap->leftsidebar_width = 0; $cap->rightsidebar_width = $rightsidebar_width; break;
  111.             case 'single-event.php': $cap->leftsidebar_width = 0; $cap->rightsidebar_width = $rightsidebar_width; break;
  112.             case 'single-venue.php': $cap->leftsidebar_width = 0; $cap->rightsidebar_width = $rightsidebar_width; break;
  113.             case 'venue-template.php': $cap->leftsidebar_width = 0; $cap->rightsidebar_width = $rightsidebar_width; break;
  114.             case 'left-and-right-sidebar.php': $cap->leftsidebar_width = $leftsidebar_width; $cap->rightsidebar_width = $rightsidebar_width; break;
  115.             case 'full-width.php': $cap->leftsidebar_width = 0; $cap->rightsidebar_width = 0; break;
  116.             case 'full-width-venue.php': $cap->leftsidebar_width = 0; $cap->rightsidebar_width = 0; break;
  117.         }
  118.  
  119.     }
  120.    
  121.     /**
  122.      * header: add div 'innerrim' before header if the header is not set to full width
  123.      *
  124.      * located: header.php - do_action( 'bp_before_header' )
  125.      *
  126.      * @package Custom Community
  127.      * @since 1.8.3
  128.      */
  129.     function innerrim_before_header(){
  130.         global $cap;
  131.        
  132.         if (($cap->header_width != "full-width") || ($cap->header_width != "full-width-venue")) {
  133.             echo '<div id="innerrim">';
  134.    
  135.         }
  136.     }
  137.    
  138.     /**
  139.      * header: add div 'innerrim' after header if the header is set to full width
  140.      *
  141.      * located: header.php do_action( 'bp_after_header' ) on line 84
  142.      *
  143.      * @package Custom Community
  144.      * @since 1.8.3
  145.      */
  146.     function innerrim_after_header(){
  147.         global $cap;
  148.        
  149.         if (($cap->header_width == "full-width") || ($cap->header_width == "full-width-venue")) {
  150.             echo '<div id="innerrim">';
  151.         }
  152.     }
  153.    
  154.     /**
  155.      * header: add a search field in the header
  156.      *
  157.      * located: header.php do_action( 'bp_after_header_nav' )
  158.      *
  159.      * @package Custom Community
  160.      * @since 1.8.3
  161.      */
  162.    
  163.     function menue_enable_search(){
  164.         global $cap;
  165.  
  166.         if(defined('BP_VERSION')){
  167.             if($cap->menue_enable_search){?>
  168.             <div id="search-bar" role="search">
  169.                 <div class="padder">
  170.                    
  171.                         <form action="<?php echo bp_search_form_action() ?>" method="post" id="search-form">
  172.                             <input type="text" id="search-terms" name="search-terms" value="<?php echo isset( $_REQUEST['s'] ) ? esc_attr( $_REQUEST['s'] ) : ''; ?>" />
  173.                             <?php echo bp_search_form_type_select() ?>
  174.  
  175.                             <input type="submit" name="search-submit" id="search-submit" value="<?php _e( 'Search', 'cc' ) ?>" />
  176.  
  177.                             <?php wp_nonce_field( 'bp_search_form' ) ?>
  178.  
  179.                         </form><!-- #search-form -->
  180.  
  181.                 <?php do_action( 'bp_search_login_bar' ) ?>
  182.  
  183.                 </div><!-- .padder -->
  184.             </div><!-- #search-bar -->
  185.             <?php
  186.             }
  187.         }
  188.     }
  189.    
  190.     /**
  191.      * header: add a header logo in the header
  192.      *
  193.      * located: header.php do_action( 'bp_before_access' )
  194.      *
  195.      * @package Custom Community
  196.      * @since 1.8.3
  197.      */
  198.     function header_logo(){
  199.         global $cap;   
  200.             if(is_home()): ?>
  201.             <div id="logo">
  202.             <h1><a href="<?php echo site_url() ?>" title="<?php _e( 'Home', 'cc' ) ?>"><?php if(defined('BP_VERSION')){ bp_site_name(); } else { bloginfo('name'); } ?></a></h1>
  203.             <div id="blog-description"><?php bloginfo('description'); ?></div>
  204.            
  205.             <?php if($cap->logo){ ?>
  206.             <a href="<?php echo site_url() ?>" title="<?php _e( 'Home', 'cc' ) ?>"><img src="<?php echo $cap->logo?>" alt="<?php if(defined('BP_VERSION')){ bp_site_name(); } else { bloginfo('name'); } ?>"></img></a>
  207.             <?php } ?>
  208.             </div>
  209.         <?php else: ?>
  210.             <div id="logo">
  211.             <h4><a href="<?php echo site_url() ?>" title="<?php _e( 'Home', 'cc' ) ?>"><?php if(defined('BP_VERSION')){ bp_site_name(); } else { bloginfo('name'); } ?></a></h4>
  212.             <div id="blog-description"><?php bloginfo('description'); ?></div>
  213.             <?php if($cap->logo){ ?>
  214.             <a href="<?php echo site_url() ?>" title="<?php _e( 'Home', 'cc' ) ?>"><img src="<?php echo $cap->logo?>" alt="<?php if(defined('BP_VERSION')){ bp_site_name(); } else { bloginfo('name'); } ?>"></img></a>
  215.             <?php } ?>
  216.             </div>
  217.         <?php endif;
  218.     }
  219.    
  220.     /**
  221.      * header: add the buddypress dropdown navigation to the menu
  222.      *
  223.      * located: header.php do_action( 'bp_menu' )
  224.      *
  225.      * @package Custom Community
  226.      * @since 1.8.3
  227.      */
  228.     function bp_menu(){
  229.         global $cap;   
  230.    
  231.         if(!defined('BP_VERSION')) :
  232.             if($cap->menue_disable_home == true){ ?>
  233.                 <ul>
  234.                     <li id="nav-home"<?php if ( is_home() ) : ?> class="page_item current-menu-item"<?php endif; ?>>
  235.                         <a href="<?php echo site_url() ?>" title="<?php _e( 'Home', 'cc' ) ?>"><?php _e( 'Home', 'cc' ) ?></a>
  236.                     </li>
  237.                 </ul>
  238.             <?php } ?>
  239.         <?php else : ?>
  240.             <ul>
  241.             <?php if($cap->menue_disable_home == true){ ?>
  242.                 <li id="nav-home"<?php if ( is_front_page() ) : ?> class="page_item current-menu-item"<?php endif; ?>>
  243.                     <a href="<?php echo site_url() ?>" title="<?php _e( 'Home', 'cc' ) ?>"><?php _e( 'Home', 'cc' ) ?></a>
  244.                 </li>
  245.             <?php }?>
  246.                 <?php if($cap->menue_enable_community == true){ ?>
  247.                 <li id="nav-community"<?php if ( bp_is_page( BP_ACTIVITY_SLUG ) || (bp_is_page( BP_MEMBERS_SLUG ) || bp_is_user()) || (bp_is_page( BP_GROUPS_SLUG ) || bp_is_group()) || bp_is_page( BP_FORUMS_SLUG ) || bp_is_page( BP_BLOGS_SLUG ) )  : ?> class="page_item current-menu-item"<?php endif; ?>>
  248.                     <a href="<?php echo site_url() ?>/<?php echo BP_ACTIVITY_SLUG ?>/" title="<?php _e( 'Community', 'cc' ) ?>"><?php _e( 'Community', 'cc' ) ?></a>
  249.                     <ul class="children">
  250.                         <?php if ( 'activity' != bp_dtheme_page_on_front() && bp_is_active( 'activity' ) ) : ?>
  251.                             <li<?php if ( bp_is_page( BP_ACTIVITY_SLUG ) ) : ?> class="selected"<?php endif; ?>>
  252.                                 <a href="<?php echo site_url() ?>/<?php echo BP_ACTIVITY_SLUG ?>/" title="<?php _e( 'Activity', 'cc' ) ?>"><?php _e( 'Activity', 'cc' ) ?></a>
  253.                             </li>
  254.                         <?php endif; ?>
  255.        
  256.                         <li<?php if ( bp_is_page( BP_MEMBERS_SLUG ) || bp_is_user() ) : ?> class="selected"<?php endif; ?>>
  257.                             <a href="<?php echo site_url() ?>/<?php echo BP_MEMBERS_SLUG ?>/" title="<?php _e( 'Members', 'cc' ) ?>"><?php _e( 'Members', 'cc' ) ?></a>
  258.                         </li>
  259.        
  260.                         <?php if ( bp_is_active( 'groups' ) ) : ?>
  261.                             <li<?php if ( bp_is_page( BP_GROUPS_SLUG ) || bp_is_group() ) : ?> class="selected"<?php endif; ?>>
  262.                                 <a href="<?php echo site_url() ?>/<?php echo BP_GROUPS_SLUG ?>/" title="<?php _e( 'Groups', 'cc' ) ?>"><?php _e( 'Groups', 'cc' ) ?></a>
  263.                             </li>
  264.                             <?php if ( bp_is_active( 'forums' ) && ( function_exists( 'bp_forums_is_installed_correctly' ) && !(int) bp_get_option( 'bp-disable-forum-directory' ) ) && bp_forums_is_installed_correctly() ) : ?>
  265.                                 <li<?php if ( bp_is_page( BP_FORUMS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
  266.                                     <a href="<?php echo site_url() ?>/<?php echo BP_FORUMS_SLUG ?>/" title="<?php _e( 'Forums', 'cc' ) ?>"><?php _e( 'Forums', 'cc' ) ?></a>
  267.                                 </li>
  268.                             <?php endif; ?>
  269.                         <?php endif; ?>
  270.        
  271.                         <?php if ( bp_is_active( 'blogs' ) && is_multisite() ) : ?>
  272.                             <li<?php if ( bp_is_page( BP_BLOGS_SLUG ) ) : ?> class="selected"<?php endif; ?>>
  273.                                 <a href="<?php echo site_url() ?>/<?php echo BP_BLOGS_SLUG ?>/" title="<?php _e( 'Blogs', 'cc' ) ?>"><?php _e( 'Blogs', 'cc' ) ?></a>
  274.                             </li>
  275.                         <?php endif; ?>
  276.                     </ul>
  277.                 </li>
  278.                 <?php do_action( 'bp_nav_items' ); ?>
  279.                 <?php } ?>
  280.             </ul>
  281.         <?php endif;
  282.         }
  283.  
  284.    
  285.     function remove_home_nav_from_fallback( $args ) {
  286.         $args['show_home'] = false;
  287.         return $args;
  288.     }
  289.    
  290.     /**
  291.      * header: add the top slider to the homepage, all pages, or just on specific pages
  292.      *
  293.      * !!! this function needs to be rewritten !!!
  294.      *
  295.      * located: header.php do_action( 'bp_after_header' )
  296.      *
  297.      * @package Custom Community
  298.      * @since 1.8.3
  299.      */
  300.     function slideshow_home(){
  301.         global $cap;   
  302.         $cc_page_options=cc_get_page_meta();
  303.    
  304.         if(defined('BP_VERSION')){
  305.             if($cap->enable_slideshow_home == 'all' || $cap->enable_slideshow_home == 'home' && is_home() || $cap->enable_slideshow_home  == 'home' && is_front_page() || $cap->enable_slideshow_home == 'home' && bp_is_component_front_page( 'activity' ) || is_page() && isset($cc_page_options) && $cc_page_options['cc_page_slider_on'] == 1){
  306.                 echo cc_slidertop(); // located under wp/templatetags
  307.             }
  308.         } elseif($cap->enable_slideshow_home == 'all' || $cap->enable_slideshow_home == 'home' && is_home() || $cap->enable_slideshow_home == 'home' && is_front_page() || is_page() && isset($cc_page_options) && $cc_page_options['cc_page_slider_on'] == 1){
  309.             echo cc_slidertop(); // located under wp/templatetags
  310.         }
  311.     }
  312.    
  313.     /**
  314.      * header: add the favicon icon to the site
  315.      *
  316.      * located: header.php do_action( 'favicon' )
  317.      *
  318.      * @package Custom Community
  319.      * @since 1.8.3
  320.      */
  321.     function favicon(){
  322.         global $cap;   
  323.        
  324.         if($cap->favicon != '') {
  325.             echo '<link rel="shortcut icon" href="'.$cap->favicon.'" />';
  326.         }
  327.     }
  328.    
  329.  
  330.     /**
  331.      * footer: add div 'innerrim' before footer if the footer is set to full width
  332.      *
  333.      * located: footer.php do_action( 'bp_before_footer' )
  334.      *
  335.      * @package Custom Community
  336.      * @since 1.8.3
  337.      */
  338.     function innerrim_before_footer(){
  339.         global $cap;
  340.        
  341.         if ($cap->footer_width == "full-width") {
  342.             echo '</div><!-- #innerrim -->';
  343.         }
  344.     }
  345.  
  346.     /**
  347.      * footer: add div 'innerrim' after footer if the footer is not set to full width
  348.      *
  349.      * located: footer.php do_action( 'bp_after_footer' )
  350.      *
  351.      * @package Custom Community
  352.      * @since 1.8.3
  353.      */
  354.     function innerrim_after_footer(){
  355.         global $cap;
  356.        
  357.         if ($cap->footer_width != "full-width") {
  358.             echo '</div><!-- #innerrim -->';
  359.         }
  360.     }
  361.  
  362.     /**
  363.      * footer: add the sidebars and their default widgets to the footer
  364.      *
  365.      * located: footer.php do_action( 'bp_after_footer' )
  366.      *
  367.      * @package Custom Community
  368.      * @since 1.8.3
  369.      */
  370.     function footer_content(){
  371.         global $cap;
  372.         if( ! dynamic_sidebar( 'footerfullwidth' )) :
  373.             if($cap->preview == true){ ?>
  374.                 <div class="widget" style="margin-bottom: 0; padding: 12px; border: 1px solid #dddddd;">
  375.                         <h3 class="widgettitle" ><?php _e('20 widget areas all over the site', 'cc'); ?></h3>
  376.                         <div><p style="font-size: 16px; line-height:170%;">4 header + 4 footer widget areas (2 full width and 6 columns). <br>
  377.                         6 widget areas for members + 6 for groups.
  378.                         </p></div>
  379.                
  380.                 </div>
  381.             <?php } ?> 
  382.         <?php endif; ?>
  383.    
  384.         <?php  if (is_active_sidebar('footerleft') || $cap->preview == true ){ ?>
  385.         <div class="widgetarea cc-widget">
  386.             <?php if( ! dynamic_sidebar( 'footerleft' )){ ?>
  387.                 <div class="widget">
  388.                     <h3 class="widgettitle" ><?php _e('Links', 'cc'); ?></h3>
  389.                     <ul>
  390.                         <?php wp_list_bookmarks('title_li=&categorize=0&orderby=id'); ?>
  391.                     </ul>
  392.                 </div>
  393.             <?php } ?>
  394.         </div>
  395.         <?php  } ?>
  396.    
  397.         <?php if (is_active_sidebar('footercenter') || $cap->preview == true){ ?>
  398.         <div <?php if(!is_active_sidebar('footerleft') && $cap->preview != true ) { echo 'style="margin-left: 34% !important;"'; } ?> class="widgetarea cc-widget">
  399.             <?php if( ! dynamic_sidebar( 'footercenter' )){ ?>
  400.                 <div class="widget">
  401.                     <h3 class="widgettitle" ><?php _e('Archives', 'cc'); ?></h3>
  402.                     <ul>
  403.                         <?php wp_get_archives( 'type=monthly' ); ?>
  404.                     </ul>
  405.                 </div>             
  406.             <?php } ?>
  407.         </div>
  408.         <?php } ?>
  409.    
  410.         <?php if (is_active_sidebar('footerright') || $cap->preview == true ){ ?>
  411.         <div class="widgetarea cc-widget cc-widget-right">
  412.             <?php if( ! dynamic_sidebar( 'footerright' )){ ?>
  413.                 <div class="widget">
  414.                     <h3 class="widgettitle" ><?php _e('Meta', 'cc'); ?></h3>
  415.                     <ul>
  416.                         <?php wp_register(); ?>
  417.                         <li><?php wp_loginout(); ?></li>
  418.                         <?php wp_meta(); ?>
  419.                     </ul>
  420.                 </div>
  421.             <?php } ?>
  422.         </div>
  423.         <?php } ?>
  424.    
  425.         <div class="clear"></div>
  426.         <br />
  427.         <?php if($cap->disable_credits_footer != false ){ ?>
  428.             <br />
  429.         <!--    <div class="credits"><?php printf( __( '%s is proudly powered by <a class="credits" href="http://wordpress.org">WordPress</a> and <a class="credits" href="http://buddypress.org">BuddyPress</a>. ', 'cc' ), bloginfo('name') ); ?>
  430.             Just another <a class="credits" href="http://themekraft.com/all-themes/" target="_blank" title="Wordpress Theme" alt="WordPress Theme">WordPress Theme</a> developed by Themekraft.</div> -->
  431.         <?php } ?>
  432.         <?php if($cap->my_credits_footer != '' ){ ?>
  433.             <br />
  434.             <div class="credits"><?php echo $cap->my_credits_footer; ?></div>
  435.         <?php } ?>
  436.     <?php
  437.     }
  438.    
  439.  
  440.     /**
  441.      * header: add the sidebar and their default widgets to the left sidebar
  442.      *
  443.      * located: header.php do_action( 'sidebar_left' )
  444.      *
  445.      * @package Custom Community
  446.      * @since 1.8.3
  447.      */
  448.     function sidebar_left(){
  449.         global $cap, $bp, $post;
  450.        
  451.         $tmp = get_post_meta( $post->ID, '_wp_page_template', true );
  452.         if( $tmp == 'full-width.php' || $tmp == 'right-sidebar.php'  || $tmp == 'single-event.php' || $tmp == 'single-venue.php' || $tmp == 'venue-template.php')
  453.             return;
  454.         if( $tmp == 'full-width-venue.php' || $tmp == 'right-sidebar.php' || $tmp == 'single-event.php' || $tmp == 'single-venue.php' || $tmp == 'venue-template.php')
  455.             return;
  456.        
  457.         if( $tmp == 'left-and-right-sidebar.php' || $tmp == 'left-sidebar.php'){
  458.             locate_template( array( 'sidebar-left.php' ), true );
  459.             return;    
  460.         }
  461.  
  462.         $component = explode('-',$this->detect->tk_get_page_type());
  463.         if(!empty($component[2])){ 
  464.        
  465.             if($component[2] == 'groups' && !empty($component[3])) {
  466.                 if($cap->bp_groups_sidebars == 'left' || $cap->bp_groups_sidebars == 'left and right' ){
  467.                     locate_template( array( 'groups/single/group-sidebar-left.php' ), true );
  468.                 } elseif($cap->bp_groups_sidebars == "default" && $cap->sidebar_position == "left" || $cap->sidebar_position == "left and right" && $cap->bp_groups_sidebars == "default"){
  469.                     locate_template( array( 'sidebar-left.php' ), true );
  470.                 }
  471.             } elseif($component[2] == 'profile' && !empty($component[3])) {
  472.            
  473.                 if($cap->bp_profile_sidebars == 'left' || $cap->bp_profile_sidebars == 'left and right' ){
  474.                     locate_template( array( 'members/single/member-sidebar-left.php' ), true );
  475.                 } elseif( $cap->bp_profile_sidebars == "default" && $cap->sidebar_position == "left" || $cap->sidebar_position == "left and right" && $cap->bp_profile_sidebars == "default"){
  476.                     locate_template( array( 'sidebar-left.php' ), true );
  477.                 }
  478.             } else if($cap->sidebar_position == "left" || $cap->sidebar_position == "left and right"){
  479.                 locate_template( array( 'sidebar-left.php' ), true );
  480.             }  
  481.         } else {
  482.             if($cap->sidebar_position == "left" || $cap->sidebar_position == "left and right"){
  483.                 locate_template( array( 'sidebar-left.php' ), true );
  484.             }    
  485.         }
  486.     }
  487.  
  488.     /**
  489.      * footer: add the sidebar and their default widgets to the right sidebar
  490.      *
  491.      * located: footer.php do_action( 'sidebar_left' )
  492.      *
  493.      * @package Custom Community
  494.      * @since 1.8.3
  495.      */
  496.     function sidebar_right(){
  497.         global $cap, $bp, $post;
  498.    
  499.         $tmp = get_post_meta( $post->ID, '_wp_page_template', true );
  500.        
  501.         if( $tmp == 'full-width.php' || $tmp == 'left-sidebar.php')
  502.             return;
  503.         if( $tmp == 'full-width-venue.php' || $tmp == 'left-sidebar.php')
  504.             return;
  505.        
  506.         if( $tmp == 'left-and-right-sidebar.php' || $tmp == 'right-sidebar.php'){
  507.             locate_template( array( 'sidebar.php' ), true );
  508.             return;    
  509.         }
  510.        
  511.         $component = explode('-',$this->detect->tk_get_page_type());
  512.         if(!empty($component[2])){ 
  513.             if($component[2] == 'groups' && !empty($component[3])) {
  514.                 if($cap->bp_groups_sidebars == 'right' || $cap->bp_groups_sidebars == 'left and right' ){
  515.                     locate_template( array( 'groups/single/group-sidebar-right.php' ), true );
  516.                 } elseif($cap->bp_groups_sidebars == "default" && $cap->sidebar_position == "right" || $cap->sidebar_position == "left and right" && $cap->bp_groups_sidebars == "default"){
  517.                     locate_template( array( 'sidebar.php' ), true );
  518.                 }
  519.             } elseif($component[2] == 'profile' && !empty($component[3])) {
  520.                 if($cap->bp_profile_sidebars == 'right' || $cap->bp_profile_sidebars == 'left and right' ){
  521.                     locate_template( array( 'members/single/member-sidebar-right.php' ), true );
  522.                 } elseif( $cap->bp_profile_sidebars == "default" && $cap->sidebar_position == "right" || $cap->sidebar_position == "left and right" && $cap->bp_profile_sidebars == "default"){
  523.                     locate_template( array( 'sidebar.php' ), true );
  524.                 }
  525.             } else if($cap->sidebar_position == "right" || $cap->sidebar_position == "left and right"){
  526.                 locate_template( array( 'sidebar.php' ), true );
  527.             }    
  528.         } else {
  529.             if($cap->sidebar_position == "right" || $cap->sidebar_position == "left and right"){
  530.                 locate_template( array( 'sidebar.php' ), true );
  531.             }    
  532.         }
  533.        
  534.     }
  535.    
  536.     /**
  537.      * footer: add the buddypress default login widget to the right sidebar
  538.      *
  539.      * located: footer.php do_action( 'bp_inside_after_sidebar' )
  540.      *
  541.      * @package Custom Community
  542.      * @since 1.8.3
  543.      */
  544.     function login_sidebar_widget(){
  545.         global $cap;
  546.    
  547.         if(defined('BP_VERSION')) { if($cap->login_sidebar != 'off' || $cap->login_sidebar == false){ cc_login_widget();}}
  548.    
  549.     }
  550.    
  551.  
  552.     /**
  553.      * homepage: add the latest 3 posts to the default homepage in mouse-over magazine style
  554.      *
  555.      * located: index.php do_action( 'bp_before_blog_home' )
  556.      *
  557.      * @package Custom Community
  558.      * @since 1.8.3
  559.      */
  560.     function default_homepage_last_posts(){
  561.         global $cap;
  562.        
  563.         if( $cap->preview == true  || $cap->default_homepage_last_posts == 'show') {
  564.             $args = array(
  565.                 'amount' => '3',
  566.             );
  567.                
  568.             echo '<div style="margin-top:-44px;">'.cc_list_posts($args).'</div>';
  569.         }
  570.     }
  571.    
  572.  
  573.     /**
  574.      * check if to use content or excerpt and the excerpt length
  575.      *
  576.      * located: multiple places
  577.      *
  578.      * @package Custom Community
  579.      * @since 1.8.3
  580.      */
  581.     function excerpt_on(){
  582.         global $cap;
  583.    
  584.         if($cap->excerpt_on != 'content'){
  585.             add_filter('excerpt_length', 'cc_excerpt_length');
  586.             the_excerpt( __( 'Read the rest of this entry &rarr;', 'cc' ) );
  587.         } else {
  588.             the_content( __( 'Read the rest of this entry &rarr;', 'cc' ) );
  589.         }
  590.     }
  591.    
  592.  
  593.     /**
  594.      * groups home: add the sidebars and their default widgets to the groups header
  595.      *
  596.      * located: grous/home.php do_action( 'bp_before_group_home_content' )
  597.      *
  598.      * @package Custom Community
  599.      * @since 1.8.3
  600.      */
  601.     function before_group_home_content(){
  602.         global $cap;
  603.         if( $cap->bp_groups_header == false || $cap->bp_groups_header == 'on'):?>
  604.             <div id="item-header">
  605.                 <?php if( ! dynamic_sidebar( 'groupheader' )) : ?>
  606.                  <?php locate_template( array( 'groups/single/group-header.php' ), true ) ?>
  607.                 <?php endif; ?>
  608.                
  609.                 <?php if (is_active_sidebar('groupheaderleft') ){ ?>
  610.                     <div class="widgetarea cc-widget">
  611.                     <?php dynamic_sidebar( 'groupheaderleft' )?>
  612.                     </div>
  613.                 <?php } ?>
  614.                 <?php if (is_active_sidebar('groupheadercenter') ){ ?>
  615.                     <div <?php if(!is_active_sidebar('groupheaderleft')) { echo 'style="margin-left:30% !important"'; } ?> class="widgetarea cc-widget">
  616.                     <?php dynamic_sidebar( 'groupheadercenter' ) ?>
  617.                     </div>
  618.                 <?php } ?>
  619.                 <?php if (is_active_sidebar('groupheaderright') ){ ?>
  620.                     <div class="widgetarea cc-widget cc-widget-right">
  621.                     <?php dynamic_sidebar( 'groupheaderright' ) ?>
  622.                     </div>
  623.                 <?php } ?>
  624.             </div>
  625.         <?php else:?>
  626.             <div id="item-header">
  627.                 <h2><a href="<?php bp_group_permalink() ?>" title="<?php bp_group_name() ?>"><?php bp_group_name() ?></a></h2>
  628.             </div>
  629.         <?php endif;?>
  630.         <?php if($cap->bp_default_navigation == true){?>
  631.             <div id="item-nav">
  632.                 <div class="item-list-tabs no-ajax" id="object-nav">
  633.                     <ul>
  634.                         <?php bp_get_options_nav() ?>
  635.            
  636.                         <?php do_action( 'bp_group_options_nav' ) ?>
  637.                     </ul>
  638.                 </div>
  639.             </div><!-- #item-nav -->
  640.         <?php }
  641.     }  
  642.  
  643.     /**
  644.      * members home: add the sidebars and their default widgets to the members header
  645.      *
  646.      * located: members/home.php do_action( 'bp_before_member_home_content' )
  647.      *
  648.      * @package Custom Community
  649.      * @since 1.8.3
  650.      */
  651.     function before_member_home_content(){
  652.         global $cap;
  653.  
  654.         if($cap->bp_profile_header == false || $cap->bp_profile_header == 'on'): ?>
  655.             <div id="item-header">
  656.                 <?php if( ! dynamic_sidebar( 'memberheader' )) : ?>
  657.                     <?php locate_template( array( 'members/single/member-header.php' ), true ) ?>
  658.                 <?php endif; ?>
  659.                
  660.                 <div class="clear"></div>
  661.                
  662.                 <?php if (is_active_sidebar('memberheaderleft') ){ ?>
  663.                     <div class="widgetarea cc-widget">
  664.                     <?php dynamic_sidebar( 'memberheaderleft' )?>
  665.                     </div>
  666.                 <?php } ?>
  667.                 <?php if (is_active_sidebar('memberheadercenter') ){ ?>
  668.                     <div <?php if(!is_active_sidebar('memberheaderleft')) { echo 'style="margin-left:30% !important"'; } ?> class="widgetarea cc-widget">
  669.                     <?php dynamic_sidebar( 'memberheadercenter' ) ?>
  670.                     </div>
  671.                 <?php } ?>
  672.                 <?php if (is_active_sidebar('memberheaderright') ){ ?>
  673.                     <div class="widgetarea cc-widget cc-widget-right">
  674.                     <?php dynamic_sidebar( 'memberheaderright' ) ?>
  675.                     </div>
  676.                 <?php } ?>
  677.             </div>
  678.         <?php else:?>
  679.             <div id="item-header">
  680.                 <h2 class="fn"><a href="<?php bp_user_link() ?>"><?php bp_displayed_user_fullname() ?></a> <span class="highlight">@<?php bp_displayed_user_username() ?> <span>?</span></span></h2>
  681.             </div>
  682.         <?php endif;?>
  683.            
  684.         <?php if($cap->bp_default_navigation == true){?>
  685.         <div id="item-nav">
  686.             <div class="item-list-tabs no-ajax" id="object-nav">
  687.                 <ul>
  688.                     <?php bp_get_displayed_user_nav() ?>
  689.        
  690.                     <?php do_action( 'bp_member_options_nav' ) ?>
  691.                 </ul>
  692.             </div>
  693.         </div><!-- #item-nav -->
  694.         <?php }
  695.     }
  696.    
  697.  
  698.     /**
  699.      * login page: overwrite the login css by adding it to the login_head
  700.      *
  701.      * located: login.php do_action( 'login_head' )
  702.      *
  703.      * @package Custom Community
  704.      * @since 1.8.3
  705.      */
  706.     function custom_login() {
  707.         global $cap;?>
  708.         <style type="text/css">
  709.        
  710.         login h1 {
  711.             <?php if($cap->bg_loginpage_img){ ?>
  712.                 background-image: url('<?php echo $cap->bg_loginpage_img; ?>');
  713.             <?php } ?>
  714.             color:#777;
  715.         }
  716.         h1 a {
  717.             <?php if($cap->bg_loginpage_img){ ?>
  718.                 background-image: url('<?php echo $cap->bg_loginpage_img; ?>');
  719.                 height:<?php echo $cap->login_logo_height; ?>px;
  720.             <?php } ?>
  721.             clear: both;
  722.         }
  723.        
  724.         <?php if($cap->bg_loginpage_body_img || $cap->bg_loginpage_body_color){ ?>
  725.             html, boddy, .login {
  726.                 <?php if($cap->bg_loginpage_body_img){ ?>
  727.                     background-image: url('<?php echo $cap->bg_loginpage_body_img; ?>');
  728.                 <?php } ?>
  729.                 <?php if($cap->bg_loginpage_body_color){ ?>
  730.                     background-color: #<?php echo $cap->bg_loginpage_body_color; ?>;
  731.                 <?php } ?>
  732.                 height: 100%;
  733.                 padding-top: 0px;
  734.             }
  735.         <?php } ?>
  736.        
  737.         <?php if($cap->bg_loginpage_body_color){ ?>
  738.         body {
  739.             color:#<?php echo $cap->bg_loginpage_body_color; ?>;
  740.         }
  741.         <?php } ?>
  742.         #login{
  743.             margin: auto;
  744.             padding-top: 30px;
  745.         }
  746.         .login #nav a {
  747.             color:#777 !important;
  748.         }
  749.         .login #nav a:hover {
  750.             color:#777 !important;
  751.         }
  752.         .updated, .login #login_error, .login .message {
  753.             background: none;
  754.             color:#777;
  755.             border-color:#888;
  756.         }
  757.         #lostpasswordform {
  758.             border-color:#999;
  759.         }
  760.         <?php if($cap->bg_loginpage_backtoblog_fade_1 && $cap->bg_loginpage_backtoblog_fade_2){ ?>
  761.             #backtoblog {
  762.                  background: -moz-linear-gradient(center bottom , #<?php echo $cap->bg_loginpage_backtoblog_fade_1; ?>, #<?php echo $cap->bg_loginpage_backtoblog_fade_2; ?>) repeat scroll 0 0 transparent;
  763.             }
  764.         <?php } ?>
  765.         </style>
  766.     <?php
  767.     }
  768.    
  769.     /**
  770.      * check if the class 'home' exists in the body_class if buddypress is activated.
  771.      * if not, add class 'home' or 'bubble' if cc is deactivated
  772.      *
  773.      * do_action( 'body_class' )
  774.      *
  775.      * @package Custom Community
  776.      * @since 1.8.3
  777.      */
  778.     function home_body_class($classes){
  779.    
  780.         if(defined('BP_VERSION')){
  781.             if( !in_array( 'home', $classes ) ){
  782.                 if ( is_front_page() )
  783.                 $classes[] = 'home';
  784.             }
  785.         }
  786.        
  787.         if(is_home()){
  788.             $classes[] = 'bubble';
  789.         }
  790.        
  791.         return $classes;
  792.    
  793.     }
  794. }?>
Advertisement
Add Comment
Please, Sign In to add comment