Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (function_exists('wp_nav_menu')) {
- add_action( 'init', 'register_my_menus' );
- function register_my_menus() {
- register_nav_menus(
- array(
- 'navbar' => __( 'navbar' ),
- 'subnavbar' => __( 'subnavbar' ),
- )
- );
- }
- }
- /************************************************************\
- * WP NOW - Get Configuration Option
- \************************************************************/
- $wpn_config = (array)get_option('wpn_theme_options_elements');
- function get_wpn_config($var) {
- global $wpn_config;
- if(array_key_exists($var,$wpn_config)) {
- return $wpn_config[$var];
- }
- else {
- return false;
- }
- }
- /************************************************************\
- * WP NOW - Remove Default Widgets
- \************************************************************/
- function unregister_widgets()
- {
- unregister_sidebar_widget('categories');
- unregister_sidebar_widget('search');
- unregister_sidebar_widget('recent-comments');
- unregister_sidebar_widget('recent-posts');
- }
- add_action('widgets_init','unregister_widgets');
- if ( function_exists('register_sidebar') )
- {
- register_sidebars(1, array(
- 'before_title' => '',
- 'after_title' => ' <a class="wpn_toggle-expand wpn_toggle-hide" href="#"></a></span> <div class="wpn_box wpn_expandable">',
- 'before_widget' => '<span class="wpn_heading2"> ',
- 'after_widget' => '</div><div class="wpn_clear"></div><div class="wpn_box-bottom"></div>',
- ) );
- }
- /************************************************************\
- * WP NOW - Elements - Around The Site Widget
- \************************************************************/
- function widget_wpn_around_the_site()
- {
- ?>
- <!-- Around The Site // -->
- <span class="wpn_heading2">Around The Site<a class="wpn_toggle-expand wpn_toggle-hide" href="#"></a></span>
- <div class="wpn_box wpn_box-nopad wpn_box-around wpn_expandable">
- <ul class="wpn_around-tabs">
- <li><a href="#around_news" class="wpn_active">Latest News</a></li>
- <li><a href="#around_popular">Popular</a></li>
- <li><a href="#around_comments">Latest Comments</a></li>
- </ul>
- <div id="around_news" class="wpn_active">
- <ul class="wpn_list2">
- <?php $recent = new WP_Query("showposts=5"); while($recent->have_posts()) : $recent->the_post();?>
- <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><span>by <?php the_author_posts_link() ?> on <?php the_time('F jS, Y'); ?> | <a href="<? the_permalink(); ?>#comments"><?php comments_number(__('No Comments'), __('1 Comment'), __('% Comments')); ?></a></span></li>
- <?php endwhile; ?>
- </ul>
- </div>
- <div id="around_popular">
- <ul class="wpn_list2">
- <?php if(function_exists('get_mostpopular')) { get_mostpopular(); } ?>
- </ul>
- </div>
- <div id="around_comments">
- <ul class="wpn_list2">
- <?php
- global $wpdb;
- $sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author_email, comment_author, comment_date_gmt,
- comment_approved, comment_type,comment_author_url, SUBSTRING(comment_content,1,25) AS com_excerpt FROM $wpdb->comments LEFT
- OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = '1' AND comment_type
- = '' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT 5";
- $comments = $wpdb->get_results($sql);
- foreach ($comments as $comment) {
- $output .= "\n <li><a href=\"" . get_permalink($comment->ID) . "#comment-" . $comment->comment_ID . "\">".strip_tags($comment->comment_author)."</a> on <a href=\"".get_permalink($comment->ID)."\">" . $comment->post_title . "</a><span>".strip_tags($comment->com_excerpt)."</span></li>" ;
- }
- $output .= "\n";
- $output .= $post_HTML;
- echo $output;
- ?>
- </ul>
- </div>
- </div>
- <div class="wpn_box-bottom"></div>
- <!-- // Around The Site -->
- <?php
- }
- if ( function_exists('register_sidebar_widget') )
- {
- register_sidebar_widget(__('Elements: Around The Site'), 'widget_wpn_around_the_site');
- }
- /************************************************************\
- * WP NOW - Elements - Categories
- \************************************************************/
- function widget_wpn_categories()
- {
- ?>
- <!-- Categories // -->
- <span class="wpn_heading2">Categories<a class="wpn_toggle-expand wpn_toggle-hide" href="#"></a></span>
- <div class="wpn_box wpn_box-nopad wpn_expandable">
- <ul class="wpn_list">
- <?php wp_list_categories('sort_column=menu_order&title_li=&show_count=0&hierarchical=true'); ?>
- </ul>
- <div class="clear"></div>
- </div>
- <div class="wpn_box-bottom"></div>
- <!-- // Categories -->
- <?php
- }
- if ( function_exists('register_sidebar_widget') )
- {
- register_sidebar_widget(__('Elements: Categories'), 'widget_wpn_categories');
- }
- /************************************************************\
- * WP NOW - Elements - Archives
- \************************************************************/
- function widget_wpn_archives()
- {
- ?>
- <!-- Archives // -->
- <span class="wpn_heading2">Archives<a class="wpn_toggle-expand wpn_toggle-hide" href="#"></a></span>
- <div class="wpn_box wpn_box-nopad wpn_expandable">
- <ul class="wpn_list">
- <?php wp_get_archives('show_post_count=false'); ?>
- </ul>
- <div class="wpn_clear"></div>
- </div>
- <div class="wpn_box-bottom"></div>
- <!-- // Archives -->
- <?php
- }
- if ( function_exists('register_sidebar_widget') )
- {
- register_sidebar_widget(__('Elements: Archives'), 'widget_wpn_archives');
- }
- /************************************************************\
- * WP NOW - Elements - Tag Cloud
- \************************************************************/
- function widget_wpn_tag_cloud()
- {
- ?>
- <!-- Tag Cloud // -->
- <span class="wpn_heading2">Tags<a class="wpn_toggle-expand wpn_toggle-hide" href="#"></a></span>
- <div class="wpn_box wpn_expandable" id="tag_cloud">
- <?php
- if(function_exists('wp_widget_colorful_tag_cloud')) {
- wp_widget_colorful_tag_cloud(array());
- }else {
- wp_tag_cloud('smallest=8&largest=22&number=30&orderby=name');
- }
- ?>
- </div>
- <div class="wpn_box-bottom"></div>
- <!-- // Tag Cloud -->
- <?php
- }
- if ( function_exists('register_sidebar_widget') )
- {
- register_sidebar_widget(__('Elements: Tag Cloud'), 'widget_wpn_tag_cloud');
- }
- /************************************************************\
- * WP NOW - Featured Content Title Limit
- \************************************************************/
- function featured_content_title()
- {
- $title = get_the_title();
- $limit = "50";
- $pad="...";
- if(strlen($title) <= $limit)
- {
- echo $title;
- }
- else
- {
- $title = substr($title, 0, $limit) . $pad;
- echo $title;
- }
- }
- /************************************************************\
- * WP NOW - News & Updates Title Limit
- \************************************************************/
- function news_and_updates_title()
- {
- $title = get_the_title();
- $limit = "35";
- $pad="...";
- if(strlen($title) <= $limit)
- {
- echo $title;
- }
- else
- {
- $title = substr($title, 0, $limit) . $pad;
- echo $title;
- }
- }
- /************************************************************\
- * WP NOW - Category Title Limit
- \************************************************************/
- function category_title()
- {
- $title = get_the_title();
- $limit = "45";
- $pad="...";
- if(strlen($title) <= $limit)
- {
- echo $title;
- }
- else
- {
- $title = substr($title, 0, $limit) . $pad;
- echo $title;
- }
- }
- /************************************************************\
- * WP NOW - Content Limit
- \************************************************************/
- function wpn_content_limit($content, $ilimit = false)
- {
- $limit = ($ilimit) ? $ilimit : 270;
- $pad="...";
- $content = strip_tags($content);
- if(strlen($content) > $limit)
- {
- $content = substr($content,0,$limit);
- }
- echo $content.$pad;
- }
- /************************************************************\
- * WP NOW - Content Show
- \************************************************************/
- function wpn_content_show($limit)
- {
- if(is_category() || is_archive())
- {
- if (!empty($post->post_excerpt))
- {
- the_excerpt();
- }
- else
- {
- wpn_content_limit(get_the_content(), $limit);
- }
- }
- else
- {
- wpn_content_limit(get_the_content(), $limit);
- }
- }
- /************************************************************\
- * WP NOW - Nested Comments
- \************************************************************/
- function wpn_elements_comment($comment, $args, $depth)
- {
- $GLOBALS['comment'] = $comment;
- ?>
- <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
- <div class="wpn_cwrap">
- <div class="wpn_info">
- <div class="wpn_avatar"><?php echo get_avatar($comment,$size='80',$default=''. get_bloginfo('stylesheet_directory') .'/img/avatar.jpg' ); ?></div>
- <span class="wpn_author"><?php comment_author_link(); ?></span><br />
- <?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?><br />
- <?php edit_comment_link(__('Edit |'),' ','') ?>
- <?php
- comment_reply_link(array_merge($args, array(
- 'reply_text' => 'Reply',
- 'depth' => $depth,
- 'max_depth' => $args['max_depth']
- )));
- ?>
- </div>
- <div class="wpn_comment" id="comment-<?php comment_ID(); ?>">
- <?php if ($comment->comment_approved == '0') : ?>
- <strong><?php _e('» Your comment is awaiting moderation.') ?></strong><br /><br />
- <?php endif; ?>
- <?php comment_text() ?>
- </div>
- <div class="wpn_clear"></div>
- </div>
- <div class="wpn_clear"></div>
- <?php
- }
- // Theme Options
- add_action('admin_menu', 'wpn_add_options_page');
- function wpn_add_options_page() {
- add_theme_page(__('Theme Options'), __('Theme Options'), 'edit_themes', basename('./theme_options.php'), 'wpn_options_page');
- }
- require('theme_options.php');
- function wpn_render_usermenu() {
- ?>
- <ul class="wpn_menu">
- <li><a href="<?php echo get_option('home'); ?>"><span>Home</span></a></li>
- <?php
- if(get_wpn_config('menu_display') == 2) {
- $menu_filter = '&include='.get_wpn_config('menu_filter');
- }
- if(get_wpn_config('menu_display') == 3) {
- $menu_filter = '&exclude_tree='.get_wpn_config('menu_filter');
- }
- wp_list_pages('sort_column=menu_order&title_li=&depth=0'.$menu_filter);
- ?>
- </ul>
- <?php
- }
- function wpn_render_usersubmenu() {
- ?>
- <ul class="wpn_submenu">
- <?php
- if(get_wpn_config('submenu_display') == 2) {
- $submenu_filter = '&include='.get_wpn_config('submenu_filter');
- }
- if(get_wpn_config('submenu_display') == 3) {
- $submenu_filter = '&exclude='.get_wpn_config('submenu_filter');
- }
- wp_list_categories('sort_column=menu_order&title_li=&show_count=0'.$submenu_filter);
- ?>
- </ul>
- <?php
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement