Advertisement
Guest User

Untitled

a guest
May 20th, 2012
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.07 KB | None | 0 0
  1. ---------------------------------------------SIDEBAR.PHP---------------------------------------------
  2.  
  3.       <div id="linkwrap">
  4. <?php if ( is_sidebar_active('primary_widget_area') ) : ?>
  5.                 <div id="primary" class="widget-area">
  6.                         <ul class="xoxo">
  7.                                 <?php dynamic_sidebar('primary_widget_area'); ?>
  8.                         </ul>
  9.                 </div><!-- #primary .widget-area -->
  10. <?php endif; ?>
  11. <?php if ( is_active_sidebar( 'sidebar-1' ) ) : ?>
  12. <?php dynamic_sidebar( 'sidebar-1' ); ?>
  13. <?php endif; ?>  
  14. <?php if ( !function_exists('dynamic_sidebar')
  15. || !dynamic_sidebar() ) : ?>
  16. <?php endif; ?>
  17.       </div>
  18.  
  19. ---------------------------------------------FUNCTIONS.PHP---------------------------------------------
  20.  
  21. <?php
  22.  
  23.  
  24. // Make theme available for translation
  25. // Translations can be filed in the /languages/ directory
  26. load_theme_textdomain( 'your-theme', TEMPLATEPATH . '/languages' );
  27.  
  28. $locale = get_locale();
  29. $locale_file = TEMPLATEPATH . "/languages/$locale.php";
  30. if ( is_readable($locale_file) )
  31.         require_once($locale_file);
  32.  
  33.  
  34. // Get the page number
  35. function get_page_number() {
  36.     if (get_query_var('paged')) {
  37.         print ' | ' . __( 'Page ' , 'your-theme') . get_query_var('paged');
  38.     }
  39. } // end get_page_number
  40.  
  41.  
  42. // For category lists on category archives: Returns other categories except the current one (redundant)
  43.  
  44. function quickchic_widgets_init() {
  45. register_sidebar(array(
  46. 'name' => __( 'Sidebar 1', 'quickchic' ),
  47. 'id' => 'sidebar-1',
  48. 'before_widget' => '',
  49. 'after_widget' => '',
  50. 'before_title' => '<h4>',
  51. 'after_title' => '</h4>',
  52. ));
  53. }
  54. add_action( 'init', 'quickchic_widgets_init' );
  55.  
  56. function cats_meow($glue) {
  57.         $current_cat = single_cat_title( '', false );
  58.         $separator = "\n";
  59.         $cats = explode( $separator, get_the_category_list($separator) );
  60.         foreach ( $cats as $i => $str ) {
  61.                 if ( strstr( $str, ">$current_cat<" ) ) {
  62.                         unset($cats[$i]);
  63.                         break;
  64.                 }
  65.         }
  66.         if ( empty($cats) )
  67.                 return false;
  68.  
  69.         return trim(join( $glue, $cats ));
  70. } // end cats_meow
  71.  
  72.  
  73. // For tag lists on tag archives: Returns other tags except the current one (redundant)
  74. function tag_ur_it($glue) {
  75.         $current_tag = single_tag_title( '', '',  false );
  76.         $separator = "\n";
  77.         $tags = explode( $separator, get_the_tag_list( "", "$separator", "" ) );
  78.         foreach ( $tags as $i => $str ) {
  79.                 if ( strstr( $str, ">$current_tag<" ) ) {
  80.                         unset($tags[$i]);
  81.                         break;
  82.                 }
  83.         }
  84.         if ( empty($tags) )
  85.                 return false;
  86.  
  87.         return trim(join( $glue, $tags ));
  88. } // end tag_ur_it
  89.  
  90.  
  91. // Register widgetized areas
  92. function theme_widgets_init() {
  93.         // Area 1
  94.   register_sidebar( array (
  95.   'name' => 'Primary Widget Area',
  96.   'id' => 'primary_widget_area',
  97.   'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  98.   'after_widget' => "</li>",
  99.         'before_title' => '<h3 class="widget-title">',
  100.         'after_title' => '</h3>',
  101.   ) );
  102. } // end theme_widgets_init
  103.  
  104. add_action( 'init', 'theme_widgets_init' );
  105.  
  106.  
  107. // Pre-set Widgets
  108. $preset_widgets = array (
  109.         'primary_widget_area'  => array( 'search', 'pages', 'categories', 'archives' ),
  110.         'secondary_widget_area'  => array( 'links', 'meta' )
  111. );
  112. if ( !isset( $_GET['activated'] ) ) {
  113.         update_option( 'sidebars_widgets', $preset_widgets );
  114. }
  115. // update_option( 'sidebars_widgets', NULL );
  116.  
  117.  
  118. // Check for static widgets in widget-ready areas
  119. function is_sidebar_active( $index ){
  120.   global $wp_registered_sidebars;
  121.  
  122.   $widgetcolums = wp_get_sidebars_widgets();
  123.                  
  124.   if ($widgetcolums[$index]) return true;
  125.  
  126.         return false;
  127. } // end is_sidebar_active
  128.  
  129.  
  130. -------------------------------------PAGE.PHP---------------------------------------------
  131.  
  132. ...
  133. </div>
  134. <?php get_sidebar(); ?>
  135.   <div id="textwrap">
  136. ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement