Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.99 KB | None | 0 0
  1. <?php
  2.  
  3. if (function_exists('wp_nav_menu')) {
  4. add_action( 'init', 'register_my_menus' );
  5. function register_my_menus() {
  6. register_nav_menus(
  7. array(
  8. 'navbar' => __( 'navbar' ),
  9. 'subnavbar' => __( 'subnavbar' ),
  10. )
  11. );
  12. }
  13. }
  14. /************************************************************\
  15. * WP NOW - Get Configuration Option
  16. \************************************************************/
  17. $wpn_config = (array)get_option('wpn_theme_options_elements');
  18. function get_wpn_config($var) {
  19. global $wpn_config;
  20.  
  21. if(array_key_exists($var,$wpn_config)) {
  22. return $wpn_config[$var];
  23. }
  24. else {
  25. return false;
  26. }
  27. }
  28.  
  29. /************************************************************\
  30. * WP NOW - Remove Default Widgets
  31. \************************************************************/
  32.  
  33. function unregister_widgets()
  34. {
  35. unregister_sidebar_widget('categories');
  36. unregister_sidebar_widget('search');
  37. unregister_sidebar_widget('recent-comments');
  38. unregister_sidebar_widget('recent-posts');
  39. }
  40. add_action('widgets_init','unregister_widgets');
  41.  
  42. if ( function_exists('register_sidebar') )
  43. {
  44. register_sidebars(1, array(
  45. 'before_title' => '',
  46. 'after_title' => ' <a class="wpn_toggle-expand wpn_toggle-hide" href="#"></a></span> <div class="wpn_box wpn_expandable">',
  47. 'before_widget' => '<span class="wpn_heading2"> ',
  48. 'after_widget' => '</div><div class="wpn_clear"></div><div class="wpn_box-bottom"></div>',
  49. ) );
  50. }
  51.  
  52. /************************************************************\
  53. * WP NOW - Elements - Around The Site Widget
  54. \************************************************************/
  55.  
  56. function widget_wpn_around_the_site()
  57. {
  58. ?>
  59. <!-- Around The Site // -->
  60. <span class="wpn_heading2">Around The Site<a class="wpn_toggle-expand wpn_toggle-hide" href="#"></a></span>
  61. <div class="wpn_box wpn_box-nopad wpn_box-around wpn_expandable">
  62. <ul class="wpn_around-tabs">
  63. <li><a href="#around_news" class="wpn_active">Latest News</a></li>
  64. <li><a href="#around_popular">Popular</a></li>
  65. <li><a href="#around_comments">Latest Comments</a></li>
  66. </ul>
  67. <div id="around_news" class="wpn_active">
  68. <ul class="wpn_list2">
  69. <?php $recent = new WP_Query("showposts=5"); while($recent->have_posts()) : $recent->the_post();?>
  70. <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>
  71. <?php endwhile; ?>
  72. </ul>
  73. </div>
  74. <div id="around_popular">
  75. <ul class="wpn_list2">
  76. <?php if(function_exists('get_mostpopular')) { get_mostpopular(); } ?>
  77. </ul>
  78. </div>
  79. <div id="around_comments">
  80. <ul class="wpn_list2">
  81. <?php
  82. global $wpdb;
  83. $sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author_email, comment_author, comment_date_gmt,
  84. comment_approved, comment_type,comment_author_url, SUBSTRING(comment_content,1,25) AS com_excerpt FROM $wpdb->comments LEFT
  85. OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = '1' AND comment_type
  86. = '' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT 5";
  87.  
  88. $comments = $wpdb->get_results($sql);
  89.  
  90. foreach ($comments as $comment) {
  91. $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>" ;
  92. }
  93.  
  94. $output .= "\n";
  95. $output .= $post_HTML;
  96. echo $output;
  97. ?>
  98. </ul>
  99. </div>
  100. </div>
  101. <div class="wpn_box-bottom"></div>
  102. <!-- // Around The Site -->
  103. <?php
  104. }
  105. if ( function_exists('register_sidebar_widget') )
  106. {
  107. register_sidebar_widget(__('Elements: Around The Site'), 'widget_wpn_around_the_site');
  108. }
  109.  
  110. /************************************************************\
  111. * WP NOW - Elements - Categories
  112. \************************************************************/
  113.  
  114. function widget_wpn_categories()
  115. {
  116. ?>
  117. <!-- Categories // -->
  118. <span class="wpn_heading2">Categories<a class="wpn_toggle-expand wpn_toggle-hide" href="#"></a></span>
  119. <div class="wpn_box wpn_box-nopad wpn_expandable">
  120. <ul class="wpn_list">
  121. <?php wp_list_categories('sort_column=menu_order&title_li=&show_count=0&hierarchical=true'); ?>
  122. </ul>
  123. <div class="clear"></div>
  124. </div>
  125. <div class="wpn_box-bottom"></div>
  126. <!-- // Categories -->
  127. <?php
  128. }
  129. if ( function_exists('register_sidebar_widget') )
  130. {
  131. register_sidebar_widget(__('Elements: Categories'), 'widget_wpn_categories');
  132. }
  133.  
  134. /************************************************************\
  135. * WP NOW - Elements - Archives
  136. \************************************************************/
  137.  
  138. function widget_wpn_archives()
  139. {
  140. ?>
  141. <!-- Archives // -->
  142. <span class="wpn_heading2">Archives<a class="wpn_toggle-expand wpn_toggle-hide" href="#"></a></span>
  143. <div class="wpn_box wpn_box-nopad wpn_expandable">
  144. <ul class="wpn_list">
  145. <?php wp_get_archives('show_post_count=false'); ?>
  146. </ul>
  147. <div class="wpn_clear"></div>
  148. </div>
  149. <div class="wpn_box-bottom"></div>
  150. <!-- // Archives -->
  151. <?php
  152. }
  153. if ( function_exists('register_sidebar_widget') )
  154. {
  155. register_sidebar_widget(__('Elements: Archives'), 'widget_wpn_archives');
  156. }
  157.  
  158. /************************************************************\
  159. * WP NOW - Elements - Tag Cloud
  160. \************************************************************/
  161.  
  162. function widget_wpn_tag_cloud()
  163. {
  164. ?>
  165. <!-- Tag Cloud // -->
  166. <span class="wpn_heading2">Tags<a class="wpn_toggle-expand wpn_toggle-hide" href="#"></a></span>
  167. <div class="wpn_box wpn_expandable" id="tag_cloud">
  168. <?php
  169. if(function_exists('wp_widget_colorful_tag_cloud')) {
  170. wp_widget_colorful_tag_cloud(array());
  171. }else {
  172. wp_tag_cloud('smallest=8&largest=22&number=30&orderby=name');
  173. }
  174. ?>
  175. </div>
  176. <div class="wpn_box-bottom"></div>
  177. <!-- // Tag Cloud -->
  178. <?php
  179. }
  180. if ( function_exists('register_sidebar_widget') )
  181. {
  182. register_sidebar_widget(__('Elements: Tag Cloud'), 'widget_wpn_tag_cloud');
  183. }
  184.  
  185.  
  186.  
  187.  
  188.  
  189. /************************************************************\
  190. * WP NOW - Featured Content Title Limit
  191. \************************************************************/
  192.  
  193. function featured_content_title()
  194. {
  195. $title = get_the_title();
  196. $limit = "50";
  197. $pad="...";
  198. if(strlen($title) <= $limit)
  199. {
  200. echo $title;
  201. }
  202. else
  203. {
  204. $title = substr($title, 0, $limit) . $pad;
  205. echo $title;
  206. }
  207. }
  208.  
  209. /************************************************************\
  210. * WP NOW - News & Updates Title Limit
  211. \************************************************************/
  212.  
  213. function news_and_updates_title()
  214. {
  215. $title = get_the_title();
  216. $limit = "35";
  217. $pad="...";
  218. if(strlen($title) <= $limit)
  219. {
  220. echo $title;
  221. }
  222. else
  223. {
  224. $title = substr($title, 0, $limit) . $pad;
  225. echo $title;
  226. }
  227. }
  228.  
  229. /************************************************************\
  230. * WP NOW - Category Title Limit
  231. \************************************************************/
  232.  
  233. function category_title()
  234. {
  235. $title = get_the_title();
  236. $limit = "45";
  237. $pad="...";
  238. if(strlen($title) <= $limit)
  239. {
  240. echo $title;
  241. }
  242. else
  243. {
  244. $title = substr($title, 0, $limit) . $pad;
  245. echo $title;
  246. }
  247. }
  248.  
  249. /************************************************************\
  250. * WP NOW - Content Limit
  251. \************************************************************/
  252.  
  253. function wpn_content_limit($content, $ilimit = false)
  254. {
  255. $limit = ($ilimit) ? $ilimit : 270;
  256. $pad="...";
  257. $content = strip_tags($content);
  258. if(strlen($content) > $limit)
  259. {
  260. $content = substr($content,0,$limit);
  261. }
  262. echo $content.$pad;
  263. }
  264.  
  265. /************************************************************\
  266. * WP NOW - Content Show
  267. \************************************************************/
  268.  
  269. function wpn_content_show($limit)
  270. {
  271. if(is_category() || is_archive())
  272. {
  273. if (!empty($post->post_excerpt))
  274. {
  275. the_excerpt();
  276. }
  277. else
  278. {
  279. wpn_content_limit(get_the_content(), $limit);
  280. }
  281. }
  282. else
  283. {
  284. wpn_content_limit(get_the_content(), $limit);
  285. }
  286. }
  287.  
  288. /************************************************************\
  289. * WP NOW - Nested Comments
  290. \************************************************************/
  291.  
  292. function wpn_elements_comment($comment, $args, $depth)
  293. {
  294. $GLOBALS['comment'] = $comment;
  295. ?>
  296. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
  297. <div class="wpn_cwrap">
  298. <div class="wpn_info">
  299. <div class="wpn_avatar"><?php echo get_avatar($comment,$size='80',$default=''. get_bloginfo('stylesheet_directory') .'/img/avatar.jpg' ); ?></div>
  300. <span class="wpn_author"><?php comment_author_link(); ?></span><br />
  301. <?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?><br />
  302. <?php edit_comment_link(__('Edit |'),' ','') ?>
  303. <?php
  304. comment_reply_link(array_merge($args, array(
  305. 'reply_text' => 'Reply',
  306. 'depth' => $depth,
  307. 'max_depth' => $args['max_depth']
  308. )));
  309. ?>
  310. </div>
  311. <div class="wpn_comment" id="comment-<?php comment_ID(); ?>">
  312. <?php if ($comment->comment_approved == '0') : ?>
  313. <strong><?php _e('&raquo; Your comment is awaiting moderation.') ?></strong><br /><br />
  314. <?php endif; ?>
  315. <?php comment_text() ?>
  316. </div>
  317. <div class="wpn_clear"></div>
  318. </div>
  319. <div class="wpn_clear"></div>
  320. <?php
  321. }
  322.  
  323. // Theme Options
  324. add_action('admin_menu', 'wpn_add_options_page');
  325. function wpn_add_options_page() {
  326. add_theme_page(__('Theme Options'), __('Theme Options'), 'edit_themes', basename('./theme_options.php'), 'wpn_options_page');
  327. }
  328.  
  329. require('theme_options.php');
  330.  
  331. function wpn_render_usermenu() {
  332. ?>
  333. <ul class="wpn_menu">
  334. <li><a href="<?php echo get_option('home'); ?>"><span>Home</span></a></li>
  335. <?php
  336. if(get_wpn_config('menu_display') == 2) {
  337. $menu_filter = '&include='.get_wpn_config('menu_filter');
  338. }
  339. if(get_wpn_config('menu_display') == 3) {
  340. $menu_filter = '&exclude_tree='.get_wpn_config('menu_filter');
  341. }
  342. wp_list_pages('sort_column=menu_order&title_li=&depth=0'.$menu_filter);
  343. ?>
  344. </ul>
  345. <?php
  346. }
  347. function wpn_render_usersubmenu() {
  348. ?>
  349. <ul class="wpn_submenu">
  350. <?php
  351. if(get_wpn_config('submenu_display') == 2) {
  352. $submenu_filter = '&include='.get_wpn_config('submenu_filter');
  353. }
  354. if(get_wpn_config('submenu_display') == 3) {
  355. $submenu_filter = '&exclude='.get_wpn_config('submenu_filter');
  356. }
  357. wp_list_categories('sort_column=menu_order&title_li=&show_count=0'.$submenu_filter);
  358. ?>
  359. </ul>
  360. <?php
  361. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement