__( 'Primary Navigation', 'aerial' ), ) ); // Add default posts and comments RSS feed links to head add_theme_support( 'automatic-feed-links' ); // Make theme available for translation // Translations can be filed in the /languages/ directory load_theme_textdomain( 'aerial', TEMPLATEPATH . '/languages' ); $locale = get_locale(); $locale_file = TEMPLATEPATH . "/languages/$locale.php"; if ( is_readable( $locale_file ) ) require_once( $locale_file ); // This theme allows users to set a custom background add_custom_background(); } endif; remove_action('wp_head', 'wp_generator'); if ( ! function_exists( 'dd_the_page_number' ) ) : /** * Prints the page number currently being browsed, with a vertical bar before it. * * Used in Twenty Ten's header.php to add the page number to the HTML tag. * * @since 3.0.0 */ function dd_the_page_number() { global $paged; // Contains page number. if ( $paged >= 2 ) echo ' » ' . sprintf( __( 'Page %s' , 'aerial' ), $paged ); } endif; /** * Register widgetized areas. * * To override dd_widgets_init() in a child theme, remove the action hook and add your own * function tied to the init hook. * @uses register_sidebar */ function dd_widgets_init() { // Sidebar Area register_sidebar( array ( 'name' => __( 'Sidebar Area', 'aerial' ), 'id' => 'sidebar', 'description' => __( 'Sidebar Area', 'aerial' ), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => "</div>", 'before_title' => '<h3 class="widget_title">', 'after_title' => '</h3>', ) ); // HomePage Area 1 register_sidebar( array ( 'name' => __( 'Home Page Area 1', 'aerial' ), 'id' => 'homewidget1', 'description' => __( 'Home Page Area 1', 'aerial' ), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => "</div>", 'before_title' => '<h2 class="widget_title">', 'after_title' => '</h2>', ) ); // HomePage Area 2 register_sidebar( array ( 'name' => __( 'Home Page Area 2', 'aerial' ), 'id' => 'homewidget2', 'description' => __( 'Home Page Widget 2', 'aerial' ), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => "</div>", 'before_title' => '<h2 class="widget_title">', 'after_title' => '</h2>', ) ); // HomePage Area 3 register_sidebar( array ( 'name' => __( 'Home Page Area 3', 'aerial' ), 'id' => 'homewidget3', 'description' => __( 'Home Page Area 3', 'aerial' ), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => "</div>", 'before_title' => '<h2 class="widget_title">', 'after_title' => '</h2>', ) ); // HomePage Area 4 register_sidebar( array ( 'name' => __( 'Home Page Area 4', 'aerial' ), 'id' => 'homewidget4', 'description' => __( 'Home Page Area 4', 'aerial' ), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => "</div>", 'before_title' => '<h2 class="widget_title">', 'after_title' => '</h2>', ) ); //HomePage Area 5 register_sidebar( array ( 'name' => __( 'Home Page Area 5', 'aerial' ), 'id' => 'homewidget5', 'description' => __( 'Home Page Area 5', 'aerial' ), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => "</div>", 'before_title' => '<h2 class="widget_title">', 'after_title' => '</h2>', ) ); // Footer Area 1 register_sidebar( array ( 'name' => __( 'Footer Area 1', 'aerial' ), 'id' => 'footerwidget1', 'description' => __( 'Footer Area 1', 'aerial' ), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => "</div>", 'before_title' => '<h2 class="widget_title">', 'after_title' => '</h2>', ) ); // Footer Area 2 register_sidebar( array ( 'name' => __( 'Footer Area 2', 'aerial' ), 'id' => 'footerwidget2', 'description' => __( 'Footer Area 2', 'aerial' ), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => "</div>", 'before_title' => '<h2 class="widget_title">', 'after_title' => '</h2>', ) ); // Footer Area 3 register_sidebar( array ( 'name' => __( 'Footer Area 3', 'aerial' ), 'id' => 'footerwidget3', 'description' => __( 'Footer Area 3', 'aerial' ), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => "</div>", 'before_title' => '<h2 class="widget_title">', 'after_title' => '</h2>', ) ); } add_action( 'init', 'dd_widgets_init' ); /** * Sets the content limit length to xx characters defined in theme files panel. * @return int */ function the_content_limit($max_char) { $content = get_the_content(); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); $content = strip_tags($content); if (strlen($_GET['p']) > 0) { echo $content; } else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) { $content = substr($content, 0, $espacio); $content = $content; echo $content; } else { echo $content; } } /** Allows users to limit the number or words that are displayed when they want the title or content of a post to appear. * Instead of the_title() or the_content(), use <?php dd_limit_word(); ?> within your loop to limit the words for each. */ function dd_limit_word($max_word = 40, $more_text = '...', $more_link_text = '', $limit_type = 'title') { if ($limit_type == 'title') { $limiter = get_the_title(); } else { $limiter = get_the_content(); } $limiter = apply_filters('the_title', $limiter); $limiter = strip_tags(str_replace(']]>', ']]>', $limiter)); $trim = explode(' ', $limiter); if(count($trim) > $max_word) { $l = $max_word; for ($i=0; $i<=$l ; $i++) $output .= $trim[$i] . ' '; echo $output; echo $more_text; if ($more_link_text != '') { echo ' <a href="'; echo the_permalink(); echo '">'.$more_link_text.'</a>'; } } else { echo $limiter; } } /** Allows users to limit the number or characters that are displayed when they want the title or content of a post to appear. * Instead of the_title() or the_content(), use <?php dd_limit_char(); ?> within your loop to limit the words for each. */ function dd_limit_char($max_char = 10, $more_text = '...', $more_link_text = '', $limit_type = 'title') { if ($limit_type == 'title') { $limiter = get_the_title(); } else { $limiter = get_the_content(); } $limiter = apply_filters('the_title', $limiter); $limiter = strip_tags(str_replace(']]>', ']]>', $limiter)); if (strlen($limiter) > $max_char) { echo substr($limiter, 0, $max_char+1); echo $more_text; if ($more_link_text != '') { echo ' <a href="'; echo the_permalink(); echo '">'.$more_link_text.'</a>'; } } else { echo $limiter; } } /** * Sets the "read more" link to something pretty. * * To override this link in a child theme, remove the filter and add your own * function tied to the excerpt_more filter hook. * * @since 3.0.0 * @return string A pretty 'More Details' link. */ function dd_excerpt_more( $more ) { return ' … <br /><a href="'. get_permalink() . '">' . __('<span class="meta-nav">More Details</span>', 'aerial') . '</a>'; } add_filter( 'excerpt_more', 'dd_excerpt_more' ); /** * Template for comments and pingbacks. * * To override this walker in a child theme without modifying the comments template * simply create your own dd_comment(), and that function will be used instead. * * Used as a callback by wp_list_comments() for displaying the comments. * * @since Aerial 1.0 */ if ( ! function_exists( 'dd_comment' ) ) : function dd_comment( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; switch ( $comment->comment_type ) : case '' : ?> <li <?php comment_class('clearfix'); ?> id="li-comment-<?php comment_ID(); ?>"> <div id="comment-<?php comment_ID(); ?>"> <div class="comment-meta commentmetadata"> <?php echo get_avatar( $comment, 70 ); ?> <?php printf( __( '%s ', 'pmchina' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?> <?php if ( $comment->comment_approved == '0' ) : ?> <em><?php _e( 'Your comment is awaiting moderation.', 'pmchina' ); ?></em> <?php endif; ?> <a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>"> <?php /* translators: 1: date, 2: time */ printf( __( '( %1$s / %2$s )', 'pmchina' ), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'pmchina' ), ' ' ); ?> </div><!-- .comment-meta .commentmetadata --> <div class="comment-body"><?php comment_text(); ?></div> <div class="reply"> <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?> </div><!-- .reply --> </div><!-- #comment-## --> <?php break; case 'pingback' : case 'trackback' : ?> <li class="post pingback"> <p><?php _e( 'Pingback:', 'pmchina' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __('(Edit)', 'pmchina'), ' ' ); ?></p> <?php break; endswitch; } endif; ### Function: Page Navigation Options function pagenavi_init() { $pagenavi_options = array(); $pagenavi_options['pages_text'] = __('Page %CURRENT_PAGE% of %TOTAL_PAGES%','wp-pagenavi'); $pagenavi_options['current_text'] = '%PAGE_NUMBER%'; $pagenavi_options['page_text'] = '%PAGE_NUMBER%'; $pagenavi_options['first_text'] = __('« First','wp-pagenavi'); $pagenavi_options['last_text'] = __('Last »','wp-pagenavi'); $pagenavi_options['next_text'] = __('»','wp-pagenavi'); $pagenavi_options['prev_text'] = __('«','wp-pagenavi'); $pagenavi_options['dotright_text'] = __('...','wp-pagenavi'); $pagenavi_options['dotleft_text'] = __('...','wp-pagenavi'); $pagenavi_options['style'] = 1; $pagenavi_options['num_pages'] = 10; $pagenavi_options['always_show'] = 0; return $pagenavi_options; } ### Function: Page Navigation: Boxed Style Paging function wp_pagenavi($before = '', $after = '') { global $wpdb, $wp_query; $pagenavi_options = array(); $pagenavi_options = pagenavi_init(); if (!is_single()) { $request = $wp_query->request; $posts_per_page = intval(get_query_var('posts_per_page')); $paged = intval(get_query_var('paged')); $numposts = $wp_query->found_posts; $max_page = $wp_query->max_num_pages; /* $numposts = 0; if(strpos(get_query_var('tag'), " ")) { preg_match('#^(.*)\sLIMIT#siU', $request, $matches); $fromwhere = $matches[1]; $results = $wpdb->get_results($fromwhere); $numposts = count($results); } else { preg_match('#FROM\s*+(.+?)\s+(GROUP BY|ORDER BY)#si', $request, $matches); $fromwhere = $matches[1]; $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere"); } $max_page = ceil($numposts/$posts_per_page); */ if(empty($paged) || $paged == 0) { $paged = 1; } $pages_to_show = intval($pagenavi_options['num_pages']); $pages_to_show_minus_1 = $pages_to_show-1; $half_page_start = floor($pages_to_show_minus_1/2); $half_page_end = ceil($pages_to_show_minus_1/2); $start_page = $paged - $half_page_start; if($start_page <= 0) { $start_page = 1; } $end_page = $paged + $half_page_end; if(($end_page - $start_page) != $pages_to_show_minus_1) { $end_page = $start_page + $pages_to_show_minus_1; } if($end_page > $max_page) { $start_page = $max_page - $pages_to_show_minus_1; $end_page = $max_page; } if($start_page <= 0) { $start_page = 1; } if($max_page > 1 || intval($pagenavi_options['always_show']) == 1) { $pages_text = str_replace("%CURRENT_PAGE%", number_format_i18n($paged), $pagenavi_options['pages_text']); $pages_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $pages_text); echo $before.'<div class="wp-pagenavi">'."\n"; switch(intval($pagenavi_options['style'])) { case 1: if(!empty($pages_text)) { echo '<span class="pages"> '.$pages_text.' </span>'; } if ($start_page >= 2 && $pages_to_show < $max_page) { $first_page_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $pagenavi_options['first_text']); echo '<a href="'.clean_url(get_pagenum_link()).'" title="'.$first_page_text.'"> '.$first_page_text.' </a>'; if(!empty($pagenavi_options['dotleft_text'])) { echo '<span class="extend"> '.$pagenavi_options['dotleft_text'].' </span>'; } } previous_posts_link($pagenavi_options['prev_text']); for($i = $start_page; $i <= $end_page; $i++) { if($i == $paged) { $current_page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['current_text']); echo '<span class="current"> '.$current_page_text.' </span>'; } else { $page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['page_text']); echo '<a href="'.clean_url(get_pagenum_link($i)).'" title="'.$page_text.'"> '.$page_text.' </a>'; } } next_posts_link($pagenavi_options['next_text'], $max_page); if ($end_page < $max_page) { if(!empty($pagenavi_options['dotright_text'])) { echo '<span class="extend"> '.$pagenavi_options['dotright_text'].' </span>'; } $last_page_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $pagenavi_options['last_text']); echo '<a href="'.clean_url(get_pagenum_link($max_page)).'" title="'.$last_page_text.'"> '.$last_page_text.' </a>'; } break; case 2; echo '<form action="'.htmlspecialchars($_SERVER['PHP_SELF']).'" method="get">'."\n"; echo '<select size="1" onchange="document.location.href = this.options[this.selectedIndex].value;">'."\n"; for($i = 1; $i <= $max_page; $i++) { $page_num = $i; if($page_num == 1) { $page_num = 0; } if($i == $paged) { $current_page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['current_text']); echo '<option value="'.clean_url(get_pagenum_link($page_num)).'" selected="selected" class="current">'.$current_page_text."</option>\n"; } else { $page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['page_text']); echo '<option value="'.clean_url(get_pagenum_link($page_num)).'">'.$page_text."</option>\n"; } } echo "</select>\n"; echo "</form>\n"; break; } echo '</div>'.$after."\n"; } } }?>