Advertisement
wzislam

My Functions.php

Jan 14th, 2013
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.70 KB | None | 0 0
  1. <?php
  2. // Make theme available for translation
  3. // Translations can be filed in the /languages/ directory
  4. load_theme_textdomain( 'nanodesigns', get_template_directory() . '/languages' );
  5. $locale = get_locale();
  6. $locale_file = get_template_directory() . "/languages/$locale.php";
  7. if ( is_readable($locale_file) )
  8.         require_once($locale_file);
  9.  
  10.  
  11. // Get the page number
  12. function get_page_number() {
  13.     if (get_query_var('paged')) {
  14.         print ' | ' . __( 'Page ' , 'nanodesigns') . get_query_var('paged');
  15.     }
  16. } // end get_page_number
  17.  
  18.  
  19. // For category lists on category archives: Returns other categories except the current one (redundant)
  20. function cats_meow($glue) {
  21.         $current_cat = single_cat_title( '', false );
  22.         $separator = "\n";
  23.         $cats = explode( $separator, get_the_category_list($separator) );
  24.         foreach ( $cats as $i => $str ) {
  25.                 if ( strstr( $str, ">$current_cat<" ) ) {
  26.                         unset($cats[$i]);
  27.                         break;
  28.                 }
  29.         }
  30.         if ( empty($cats) )
  31.                 return false;
  32.  
  33.         return trim(join( $glue, $cats ));
  34. } // end cats_meow
  35.  
  36.  
  37. // For tag lists on tag archives: Returns other tags except the current one (redundant)
  38. function tag_ur_it($glue) {
  39.         $current_tag = single_tag_title( '', '',  false );
  40.         $separator = "\n";
  41.         $tags = explode( $separator, get_the_tag_list( "", "$separator", "" ) );
  42.         foreach ( $tags as $i => $str ) {
  43.                 if ( strstr( $str, ">$current_tag<" ) ) {
  44.                         unset($tags[$i]);
  45.                         break;
  46.                 }
  47.         }
  48.         if ( empty($tags) )
  49.                 return false;
  50.  
  51.         return trim(join( $glue, $tags ));
  52. } // end tag_ur_it
  53.  
  54.  
  55. // Register widgetized areas
  56. function theme_widgets_init() {
  57.         // Area 1
  58.   register_sidebar( array (
  59.   'name' => 'Primary Widget Area',
  60.   'id' => 'primary_widget_area',
  61.   'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  62.   'after_widget' => "</li>",
  63.         'before_title' => '<h3 class="widget-title">',
  64.         'after_title' => '</h3>',
  65.   ) );
  66.  
  67.         // Area 2
  68.   register_sidebar( array (
  69.   'name' => 'Secondary Widget Area',
  70.   'id' => 'secondary_widget_area',
  71.   'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  72.   'after_widget' => "</li>",
  73.         'before_title' => '<h3 class="widget-title">',
  74.         'after_title' => '</h3>',
  75.   ) );
  76.  
  77.           // FOOTER WIDGET AREA 1
  78.   register_sidebar( array (
  79.   'name' => 'Footer Widget 1',
  80.   'id' => 'footer_widget_1',
  81.   'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  82.   'after_widget' => "</li>",
  83.         'before_title' => '<h3 class="widget-title">',
  84.         'after_title' => '</h3>',
  85.   ) );
  86.  
  87.             // FOOTER WIDGET AREA 2
  88.   register_sidebar( array (
  89.   'name' => 'Footer Widget 2',
  90.   'id' => 'footer_widget_2',
  91.   'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  92.   'after_widget' => "</li>",
  93.         'before_title' => '<h3 class="widget-title">',
  94.         'after_title' => '</h3>',
  95.   ) );
  96.  
  97.             // FOOTER WIDGET AREA 3
  98.   register_sidebar( array (
  99.   'name' => 'Footer Widget 3',
  100.   'id' => 'footer_widget_3',
  101.   'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  102.   'after_widget' => "</li>",
  103.         'before_title' => '<h3 class="widget-title">',
  104.         'after_title' => '</h3>',
  105.   ) );
  106.  
  107. } // end theme_widgets_init
  108.  
  109. add_action( 'init', 'theme_widgets_init' );
  110.  
  111.  
  112. // Pre-set Widgets
  113. $preset_widgets = array (
  114.         'primary_widget_area'  => array( 'search', 'pages', 'categories', 'archives' ),
  115.         'secondary_widget_area'  => array( 'links', 'meta' )
  116. );
  117. if ( isset( $_GET['activated'] ) ) {
  118.         update_option( 'sidebars_widgets', $preset_widgets );
  119. }
  120. // update_option( 'sidebars_widgets', NULL );
  121.  
  122.  
  123. // Check for static widgets in widget-ready areas
  124. function is_sidebar_active( $index ){
  125.   global $wp_registered_sidebars;
  126.  
  127.   $widgetcolums = wp_get_sidebars_widgets();
  128.                  
  129.   if ($widgetcolums[$index]) return true;
  130.  
  131.         return false;
  132. } // end is_sidebar_active
  133.  
  134.  
  135. // Produces an avatar image with the hCard-compliant photo class
  136. function commenter_link() {
  137.         $commenter = get_comment_author_link();
  138.         if ( ereg( '<a[^>]* class=[^>]+>', $commenter ) ) {
  139.                 $commenter = ereg_replace( '(<a[^>]* class=[\'"]?)', '\\1url ' , $commenter );
  140.         } else {
  141.                 $commenter = ereg_replace( '(<a )/', '\\1class="url "' , $commenter );
  142.         }
  143.         $avatar_email = get_comment_author_email();
  144.         $avatar = str_replace( "class='avatar", "class='photo avatar", get_avatar( $avatar_email, 80 ) );
  145.         echo $avatar . ' <span class="fn n">' . $commenter . '</span>';
  146. } // end commenter_link
  147.  
  148.  
  149. // Custom callback to list comments in the nanodesigns style
  150. function custom_comments($comment, $args, $depth) {
  151.   $GLOBALS['comment'] = $comment;
  152.         $GLOBALS['comment_depth'] = $depth;
  153.   ?>
  154.         <li id="comment-<?php comment_ID() ?>" <?php comment_class() ?>>
  155.                 <div class="comment-author vcard"><?php commenter_link() ?></div>
  156.                 <div class="comment-meta"><?php printf(__('Posted %1$s at %2$s <span class="meta-sep">|</span> <a href="%3$s" title="Permalink to this comment">Permalink</a>', 'nanodesigns'),
  157.                                         get_comment_date(),
  158.                                         get_comment_time(),
  159.                                         '#comment-' . get_comment_ID() );
  160.                                         edit_comment_link(__('Edit', 'nanodesigns'), ' <span class="meta-sep">|</span> <span class="edit-link">', '</span>'); ?></div>
  161.   <?php if ($comment->comment_approved == '0') _e("\t\t\t\t\t<span class='unapproved'>Your comment is awaiting moderation.</span>\n", 'nanodesigns') ?>
  162.           <div class="comment-content">
  163.                 <?php comment_text() ?>
  164.                 </div>
  165.                 <?php // echo the comment reply link
  166.                         if($args['type'] == 'all' || get_comment_type() == 'comment') :
  167.                                 comment_reply_link(array_merge($args, array(
  168.                                         'reply_text' => __('Reply','nanodesigns'),
  169.                                         'login_text' => __('Log in to reply.','nanodesigns'),
  170.                                         'depth' => $depth,
  171.                                         'before' => '<div class="comment-reply-link">',
  172.                                         'after' => '</div>'
  173.                                 )));
  174.                         endif;
  175.                  } // end custom_comments
  176.  
  177.  
  178. // Custom callback to list pings
  179. function custom_pings($comment, $args, $depth) {
  180.        $GLOBALS['comment'] = $comment;
  181.         ?>
  182.                 <li id="comment-<?php comment_ID() ?>" <?php comment_class() ?>>
  183.                         <div class="comment-author"><?php printf(__('By %1$s on %2$s at %3$s', 'nanodesigns'),
  184.                                         get_comment_author_link(),
  185.                                         get_comment_date(),
  186.                                         get_comment_time() );
  187.                                         edit_comment_link(__('Edit', 'nanodesigns'), ' <span class="meta-sep">|</span> <span class="edit-link">', '</span>'); ?></div>
  188.     <?php if ($comment->comment_approved == '0') _e('\t\t\t\t\t<span class="unapproved">Your trackback is awaiting moderation.</span>\n', 'nanodesigns') ?>
  189.             <div class="comment-content">
  190.                         <?php comment_text() ?>
  191.                         </div>
  192. <?php } // end custom_pings
  193. /* --------------------------------------------------------------------------------
  194.  BUNCH OF CODES BY nanodesigns
  195. ----------------------------------------------------------------------------------- */
  196.  
  197.  
  198. // CODE FOR DEFAULT CONTENT WIDTH
  199. if ( ! isset( $content_width ) ) $content_width = 900;
  200.  
  201.  
  202.  
  203. // AUTOMATIC FEED LINKS
  204. add_theme_support( 'automatic-feed-links' );
  205.  
  206.  
  207. // CUSTOM EDITOR STYLES
  208. add_editor_style( $stylesheet );
  209.  
  210.  
  211. /* ENABLING CUSTOM MENUS
  212. -------------------------------------------------- */
  213. //add_theme_support( 'menus' );
  214.  
  215. register_nav_menus(
  216.     array(
  217.     'primary'=>__('Primary Menu'),
  218.     'top'=>__('Top Menu'),
  219.     )
  220. );
  221.  
  222. /* -----------------------------------------------------------------
  223. * CODE FOR ADMIN PANEL FOR THE THEME
  224. --------------------------------------------------------------------*/
  225. //require_once('functions-admin.php');
  226.  
  227. /* -----------------------------------------------------------------
  228. * CUSTOM FUNCTIONS
  229. --------------------------------------------------------------------*/
  230. //require_once('functions-custom.php');
  231. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement