PageRenderTime 50ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/inc/extensions/sidebar-extensions.php

https://github.com/envex/Micro-Theme
PHP | 302 lines | 95 code | 40 blank | 167 comment | 33 complexity | 23d7616e61be2883cfa93d461db37492 MD5 | raw file
  1. <?php
  2. /**
  3. * Theme Header Extension Functions file
  4. *
  5. * The /inc/extensions/sidebar-extensions.php file defines
  6. * all of the Theme's callback functions that hook into
  7. * Theme custom and WordPress action/filter hooks in sidebar.php
  8. * and sidebar-footer.php
  9. * - micro_before_sidebar
  10. *
  11. * @link http://codex.wordpress.org/Function_Reference/add_action add_action()
  12. *
  13. * @package Micro
  14. * @copyright Copyright (c) 2011, UpThemes
  15. * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License, v2 (or newer)
  16. *
  17. * @since Micro 1.0
  18. */
  19. /**
  20. * Add Sidebar Site Details container open tag
  21. *
  22. * Adds opening DIV tag for site details container
  23. * in the main sidebar.
  24. *
  25. * This function hooked into the micro_before_sidebar hook,
  26. * which is defined in /inc/hooks.php, and which fires
  27. * in the sidebar.php template file.
  28. *
  29. * Child Themes can remove this output by calling
  30. * remove_action( 'micro_before_sidebar', 'micro_open_upper', 30 );
  31. *
  32. * Template file: sidebar.php
  33. *
  34. * @param none
  35. * @return string HTML markup for sidebar site details container open tag
  36. *
  37. * @since Micro 1.0
  38. *
  39. */
  40. function micro_open_upper(){
  41. echo '<div class="site-details">';
  42. }
  43. // Hook micro_open_upper() into micro_before_sidebar
  44. add_action( 'micro_before_sidebar', 'micro_open_upper', 30 );
  45. /**
  46. * Add Site Description to Sidebar
  47. *
  48. * Adds site description to the sidebar, after the
  49. * opening site description container HTML tag.
  50. *
  51. * This function hooked into the micro_before_sidebar hook,
  52. * which is defined in /inc/hooks.php, and which fires
  53. * in the sidebar.php template file.
  54. *
  55. * Child Themes can remove this output by calling
  56. * remove_action( 'micro_before_sidebar', 'micro_description', 60 );
  57. *
  58. * Template file: sidebar.php
  59. *
  60. * @link http://codex.wordpress.org/Function_Reference/get_bloginfo get_bloginfo()
  61. *
  62. * @param none
  63. * @return string HTML markup for sidebar site description
  64. *
  65. * @since Micro 1.0
  66. *
  67. */
  68. function micro_description(){
  69. global $up_options; ?>
  70. <aside class="blog-information">
  71. <?php if( ! isset( $up_options->logo ) ) : ?>
  72. <a class="title" href="<?php echo home_url( '/' ); ?>"><?php echo esc_html( get_bloginfo( 'name' ) ); ?></a>
  73. <?php else: ?>
  74. <a href="<?php echo home_url( '/' ); ?>"><img src="<?php echo esc_url( $up_options->logo ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>" class="logo" /></a>
  75. <?php endif; ?>
  76. <?php if( get_bloginfo( 'description' ) ): ?>
  77. <div class="desc"><?php echo esc_html( get_bloginfo( 'description' ) ); ?></div>
  78. <?php endif; ?>
  79. </aside><!-- .blog-information -->
  80. <?php
  81. }
  82. // Hook micro_description() into micro_before_sidebar
  83. add_action( 'micro_before_sidebar', 'micro_description', 60 );
  84. /**
  85. * Add Site Navigation Menu to Sidebar
  86. *
  87. * Adds site navigation menu to the sidebar, after the
  88. * opening site description container HTML tag.
  89. *
  90. * This function hooked into the micro_before_sidebar hook,
  91. * which is defined in /inc/hooks.php, and which fires
  92. * in the sidebar.php template file.
  93. *
  94. * The custom navigation menu called in this function uses
  95. * the 'primary' Theme Location. Create a custom navigation
  96. * menu via Dashboard -> Appearance -> Menus, and apply it
  97. * to the "Primary" Theme Location, for it to display here.
  98. *
  99. * If no custom navigation menu is applied to the "Primary"
  100. * Theme Location, then the menu falls back to wp_page_menu().
  101. *
  102. * Child Themes can remove this output by calling
  103. * remove_action( 'micro_before_sidebar', 'micro_sidebar_menu', 70 );
  104. *
  105. * Template file: sidebar.php
  106. *
  107. * @link http://codex.wordpress.org/Function_Reference/has_nav_menu has_nav_menu()
  108. * @link http://codex.wordpress.org/Function_Reference/wp_list_pages wp_list_pages()
  109. * @link http://codex.wordpress.org/Function_Reference/wp_nav_menu wp_nav_menu()
  110. *
  111. * @param none
  112. * @return string HTML markup for sidebar navigation menu
  113. *
  114. * @since Micro 1.0
  115. *
  116. */
  117. function micro_sidebar_menu(){
  118. if ( has_nav_menu( 'primary' ) ):
  119. wp_nav_menu(array(
  120. 'theme_location' => 'primary',
  121. 'menu' => 'navigation',
  122. 'container' => 'aside',
  123. 'menu_id' => 'navigation') );
  124. else:
  125. echo "<ul id='navigation'>";
  126. wp_list_pages( 'title_li=' );
  127. echo "</ul>";
  128. endif;
  129. }
  130. // Hook micro_sidebar_menu() into micro_before_sidebar
  131. add_action( 'micro_before_sidebar', 'micro_sidebar_menu', 70 );
  132. /**
  133. * Add Search Form to Sidebar
  134. *
  135. * Adds a search form to the sidebar, after the
  136. * site navigation menu.
  137. *
  138. * This function hooked into the micro_before_sidebar hook,
  139. * which is defined in /inc/hooks.php, and which fires
  140. * in the sidebar.php template file.
  141. *
  142. * Child Themes can remove this output by calling
  143. * remove_action( 'micro_before_sidebar', 'micro_search', 80 );
  144. *
  145. * Template file: sidebar.php
  146. *
  147. * @link http://codex.wordpress.org/Function_Reference/get_search_form get_search_form()
  148. *
  149. * @param none
  150. * @return string HTML markup for sidebar site details container open tag
  151. *
  152. * @since Micro 1.0
  153. *
  154. */
  155. function micro_search(){
  156. get_search_form();
  157. }
  158. // Hook micro_search() into micro_before_sidebar
  159. add_action( 'micro_before_sidebar', 'micro_search', 80 );
  160. /**
  161. * Add Social Links to Sidebar
  162. *
  163. * Adds a list of social profile links to the sidebar,
  164. * after the search form.
  165. *
  166. * This function hooked into the micro_before_sidebar hook,
  167. * which is defined in /inc/hooks.php, and which fires
  168. * in the sidebar.php template file.
  169. *
  170. * Child Themes can remove this output by calling
  171. * remove_action( 'micro_before_sidebar', 'micro_add_social_links', 100 );
  172. *
  173. * Template file: sidebar.php
  174. *
  175. * @link http://codex.wordpress.org/Function_Reference/get_template_directory_uri get_template_directory_uri()
  176. *
  177. * @param none
  178. * @return string HTML markup for sidebar site details container open tag
  179. *
  180. * @since Micro 1.0
  181. *
  182. */
  183. function micro_add_social_links(){
  184. global $up_options;
  185. if( $up_options->twitter || $up_options->facebook || $up_options->dribbble || $up_options->digg || $up_options->youtube || $up_options->vimeo || $up_options->tumblr || $up_options->skype || $up_options->qik || $up_options->posterous || $up_options->linkedin || $up_options->lastfm || $up_options->gowalla || $up_options->flickr || $up_options->designmoo ): ?>
  186. <aside class="social">
  187. <?php if( $up_options->twitter ): ?>
  188. <a class="twitter" href="http://twitter.com/<?php echo $up_options->twitter; ?>"><img src="<?php echo get_template_directory_uri() . "/images/icons/twitter_{$up_options->icon_size}.png"; ?>"></a>
  189. <?php endif; ?>
  190. <?php if( $up_options->facebook ): ?>
  191. <a class="facebook" href="http://facebook.com/<?php echo $up_options->facebook; ?>"><img src="<?php echo get_template_directory_uri() . "/images/icons/facebook_{$up_options->icon_size}.png"; ?>"></a>
  192. <?php endif; ?>
  193. <?php if( $up_options->dribbble ): ?>
  194. <a class="dribbble" href="http://dribbble.com/<?php echo $up_options->dribbble; ?>"><img src="<?php echo get_template_directory_uri() . "/images/icons/dribbble_{$up_options->icon_size}.png"; ?>"></a>
  195. <?php endif; ?>
  196. <?php if( $up_options->digg ): ?>
  197. <a class="digg" href="http://digg.com/<?php echo $up_options->digg; ?>"><img src="<?php echo get_template_directory_uri() . "/images/icons/digg_{$up_options->icon_size}.png"; ?>"></a>
  198. <?php endif; ?>
  199. <?php if( $up_options->youtube ): ?>
  200. <a class="youtube" href="http://youtube.com/<?php echo $up_options->youtube; ?>"><img src="<?php echo get_template_directory_uri() . "/images/icons/youtube_{$up_options->icon_size}.png"; ?>"></a>
  201. <?php endif; ?>
  202. <?php if( $up_options->vimeo ): ?>
  203. <a class="vimeo" href="http://vimeo.com/<?php echo $up_options->vimeo; ?>"><img src="<?php echo get_template_directory_uri() . "/images/icons/vimeo_{$up_options->icon_size}.png"; ?>"></a>
  204. <?php endif; ?>
  205. <?php if( $up_options->tumblr ): ?>
  206. <a class="tumblr" href="<?php echo $up_options->tumblr; ?>"><img src="<?php echo get_template_directory_uri() . "/images/icons/tumblr_{$up_options->icon_size}.png"; ?>"></a>
  207. <?php endif; ?>
  208. <?php if( $up_options->skype ): ?>
  209. <a class="skype" href="callto:<?php echo $up_options->skype; ?>"><img src="<?php echo get_template_directory_uri() . "/images/icons/skype_{$up_options->icon_size}.png"; ?>"></a>
  210. <?php endif; ?>
  211. <?php if( $up_options->qik ): ?>
  212. <a class="qik" href="http://qik.com/<?php echo $up_options->qik; ?>"><img src="<?php echo get_template_directory_uri() . "/images/icons/qik_{$up_options->icon_size}.png"; ?>"></a>
  213. <?php endif; ?>
  214. <?php if( $up_options->posterous ): ?>
  215. <a class="posterous" href="<?php echo $up_options->posterous; ?>"><img src="<?php echo get_template_directory_uri() . "/images/icons/posterous_{$up_options->icon_size}.png"; ?>"></a>
  216. <?php endif; ?>
  217. <?php if( $up_options->linkedin ): ?>
  218. <a class="linkedin" href="http://linkedin.com/<?php echo $up_options->linkedin; ?>"><img src="<?php echo get_template_directory_uri() . "/images/icons/linkedin_{$up_options->icon_size}.png"; ?>"></a>
  219. <?php endif; ?>
  220. <?php if( $up_options->lastfm ): ?>
  221. <a class="lastfm" href="http://last.fm/user/<?php echo $up_options->lastfm; ?>"><img src="<?php echo get_template_directory_uri() . "/images/icons/lastfm_{$up_options->icon_size}.png"; ?>"></a>
  222. <?php endif; ?>
  223. <?php if( $up_options->gowalla ): ?>
  224. <a class="gowalla" href="http://gowalla.com/<?php echo $up_options->gowalla; ?>"><img src="<?php echo get_template_directory_uri() . "/images/icons/gowalla_{$up_options->icon_size}.png"; ?>"></a>
  225. <?php endif; ?>
  226. <?php if( $up_options->flickr ): ?>
  227. <a class="flickr" href="http://flickr.com/photos/<?php echo $up_options->flickr; ?>"><img src="<?php echo get_template_directory_uri() . "/images/icons/flickr_{$up_options->icon_size}.png"; ?>"></a>
  228. <?php endif; ?>
  229. <?php if( $up_options->designmoo ): ?>
  230. <a class="designmoo" href="http://designmoo.com/members/<?php echo $up_options->designmoo; ?>"><img src="<?php echo get_template_directory_uri() . "/images/icons/designmoo_{$up_options->icon_size}.png"; ?>"></a>
  231. <?php endif; ?>
  232. </aside><!-- .social -->
  233. <?php endif;
  234. }
  235. // Hook micro_add_social_links() into micro_before_sidebar
  236. add_action( 'micro_before_sidebar', 'micro_add_social_links', 100 );
  237. /**
  238. * Add Sidebar Site Details container close tag
  239. *
  240. * Adds closing DIV tag for site details container
  241. * in the main sidebar.
  242. *
  243. * This function hooked into the micro_before_sidebar hook,
  244. * which is defined in /inc/hooks.php, and which fires
  245. * in the sidebar.php template file.
  246. *
  247. * Child Themes can remove this output by calling
  248. * remove_action( 'micro_before_sidebar', 'micro_close_upper', 200 );
  249. *
  250. * Template file: sidebar.php
  251. *
  252. * @param none
  253. * @return string HTML markup for sidebar site details container close tag
  254. *
  255. * @since Micro 1.0
  256. *
  257. */
  258. function micro_close_upper(){
  259. echo "</div>";
  260. }
  261. // Hook micro_close_upper() into micro_before_sidebar
  262. add_action( 'micro_before_sidebar', 'micro_close_upper', 200 );