PageRenderTime 14ms CodeModel.GetById 2ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

/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/**
 21 * Add Sidebar Site Details container open tag
 22 * 
 23 * Adds opening DIV tag for site details container
 24 * in the main sidebar.
 25 * 
 26 * This function hooked into the micro_before_sidebar hook, 
 27 * which is defined in /inc/hooks.php, and which fires
 28 * in the sidebar.php template file.
 29 * 
 30 * Child Themes can remove this output by calling 
 31 * remove_action( 'micro_before_sidebar', 'micro_open_upper', 30 );
 32 * 
 33 * Template file: sidebar.php
 34 * 
 35 * @param	none
 36 * @return	string	HTML markup for sidebar site details container open tag
 37 * 
 38 * @since	Micro 1.0
 39 * 
 40 */
 41function micro_open_upper(){
 42
 43	echo '<div class="site-details">';
 44
 45}
 46// Hook micro_open_upper() into micro_before_sidebar
 47add_action( 'micro_before_sidebar', 'micro_open_upper', 30 );
 48
 49/**
 50 * Add Site Description to Sidebar
 51 * 
 52 * Adds site description to the sidebar, after the 
 53 * opening site description container HTML tag.
 54 * 
 55 * This function hooked into the micro_before_sidebar hook, 
 56 * which is defined in /inc/hooks.php, and which fires
 57 * in the sidebar.php template file.
 58 * 
 59 * Child Themes can remove this output by calling 
 60 * remove_action( 'micro_before_sidebar', 'micro_description', 60 );
 61 * 
 62 * Template file: sidebar.php
 63 * 
 64 * @link 	http://codex.wordpress.org/Function_Reference/get_bloginfo		get_bloginfo()
 65 * 
 66 * @param	none
 67 * @return	string	HTML markup for sidebar site description
 68 * 
 69 * @since	Micro 1.0
 70 * 
 71 */
 72function micro_description(){
 73	global $up_options; ?>
 74
 75				<aside class="blog-information">
 76					<?php if( ! isset( $up_options->logo ) ) : ?>
 77					<a class="title" href="<?php echo home_url( '/' ); ?>"><?php echo esc_html( get_bloginfo( 'name' ) ); ?></a>
 78					<?php else: ?>
 79		            <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>
 80					<?php endif; ?>
 81
 82					<?php if( get_bloginfo( 'description' ) ): ?>
 83					<div class="desc"><?php echo esc_html( get_bloginfo( 'description' ) ); ?></div>
 84					<?php endif; ?>
 85				</aside><!-- .blog-information -->
 86	
 87<?php
 88}
 89// Hook micro_description() into micro_before_sidebar
 90add_action( 'micro_before_sidebar', 'micro_description', 60 );
 91
 92/**
 93 * Add Site Navigation Menu to Sidebar
 94 * 
 95 * Adds site navigation menu to the sidebar, after the 
 96 * opening site description container HTML tag.
 97 * 
 98 * This function hooked into the micro_before_sidebar hook, 
 99 * which is defined in /inc/hooks.php, and which fires
100 * in the sidebar.php template file.
101 * 
102 * The custom navigation menu called in this function uses 
103 * the 'primary' Theme Location. Create a custom navigation 
104 * menu via Dashboard -> Appearance -> Menus, and apply it 
105 * to the "Primary" Theme Location, for it to display here.
106 * 
107 * If no custom navigation menu is applied to the "Primary" 
108 * Theme Location, then the menu falls back to wp_page_menu().
109 * 
110 * Child Themes can remove this output by calling 
111 * remove_action( 'micro_before_sidebar', 'micro_sidebar_menu', 70 );
112 * 
113 * Template file: sidebar.php
114 * 
115 * @link 	http://codex.wordpress.org/Function_Reference/has_nav_menu		has_nav_menu()
116 * @link 	http://codex.wordpress.org/Function_Reference/wp_list_pages		wp_list_pages()
117 * @link 	http://codex.wordpress.org/Function_Reference/wp_nav_menu		wp_nav_menu()
118 * 
119 * @param	none
120 * @return	string	HTML markup for sidebar navigation menu
121 * 
122 * @since	Micro 1.0
123 * 
124 */
125function micro_sidebar_menu(){
126				
127				if ( has_nav_menu( 'primary' ) ):
128					wp_nav_menu(array(
129								  'theme_location'  => 'primary',
130								  'menu'            => 'navigation', 
131								  'container'       => 'aside', 
132								  'menu_id'         => 'navigation') );
133				else:
134					
135					echo "<ul id='navigation'>"; 
136					wp_list_pages( 'title_li=' );
137					echo "</ul>";
138					
139				endif;
140				
141}
142// Hook micro_sidebar_menu() into micro_before_sidebar
143add_action( 'micro_before_sidebar', 'micro_sidebar_menu', 70 );
144
145/**
146 * Add Search Form to Sidebar
147 * 
148 * Adds a search form to the sidebar, after the 
149 * site navigation menu.
150 * 
151 * This function hooked into the micro_before_sidebar hook, 
152 * which is defined in /inc/hooks.php, and which fires
153 * in the sidebar.php template file.
154 * 
155 * Child Themes can remove this output by calling 
156 * remove_action( 'micro_before_sidebar', 'micro_search', 80 );
157 * 
158 * Template file: sidebar.php
159 * 
160 * @link 	http://codex.wordpress.org/Function_Reference/get_search_form		get_search_form()
161 * 
162 * @param	none
163 * @return	string	HTML markup for sidebar site details container open tag
164 * 
165 * @since	Micro 1.0
166 * 
167 */
168function micro_search(){
169
170	get_search_form();			
171
172}
173// Hook micro_search() into micro_before_sidebar
174add_action( 'micro_before_sidebar', 'micro_search', 80 );
175
176/**
177 * Add Social Links to Sidebar
178 * 
179 * Adds a list of social profile links to the sidebar, 
180 * after the search form.
181 * 
182 * This function hooked into the micro_before_sidebar hook, 
183 * which is defined in /inc/hooks.php, and which fires
184 * in the sidebar.php template file.
185 * 
186 * Child Themes can remove this output by calling 
187 * remove_action( 'micro_before_sidebar', 'micro_add_social_links', 100 );
188 * 
189 * Template file: sidebar.php
190 * 
191 * @link 	http://codex.wordpress.org/Function_Reference/get_template_directory_uri		get_template_directory_uri()
192 * 
193 * @param	none
194 * @return	string	HTML markup for sidebar site details container open tag
195 * 
196 * @since	Micro 1.0
197 * 
198 */
199function micro_add_social_links(){
200	
201	global $up_options;
202
203	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 ): ?>
204	
205	<aside class="social">
206	
207		<?php if( $up_options->twitter ): ?>
208		<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>
209		<?php endif; ?>
210		
211		<?php if( $up_options->facebook ): ?>
212		<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>
213		<?php endif; ?>
214		
215		<?php if( $up_options->dribbble ): ?>
216		<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>
217		<?php endif; ?>
218		
219		<?php if( $up_options->digg ): ?>
220		<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>
221		<?php endif; ?>
222
223		<?php if( $up_options->youtube ): ?>
224		<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>
225		<?php endif; ?>
226		
227		<?php if( $up_options->vimeo ): ?>
228		<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>
229		<?php endif; ?>
230		
231		<?php if( $up_options->tumblr ): ?>
232		<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>
233		<?php endif; ?>
234		
235		<?php if( $up_options->skype ): ?>
236		<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>
237		<?php endif; ?>
238		
239		<?php if( $up_options->qik ): ?>
240		<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>
241		<?php endif; ?>
242		
243		<?php if( $up_options->posterous ): ?>
244		<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>
245		<?php endif; ?>
246		
247		<?php if( $up_options->linkedin ): ?>
248		<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>
249		<?php endif; ?>
250		
251		<?php if( $up_options->lastfm ): ?>
252		<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>
253		<?php endif; ?>
254		
255		<?php if( $up_options->gowalla ): ?>
256		<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>
257		<?php endif; ?>
258		
259		<?php if( $up_options->flickr ): ?>
260		<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>
261		<?php endif; ?>
262		
263		<?php if( $up_options->designmoo ): ?>
264		<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>
265		<?php endif; ?>
266		
267	</aside><!-- .social -->
268	
269	<?php endif;
270
271}
272// Hook micro_add_social_links() into micro_before_sidebar
273add_action( 'micro_before_sidebar', 'micro_add_social_links', 100 );
274
275/**
276 * Add Sidebar Site Details container close tag
277 * 
278 * Adds closing DIV tag for site details container
279 * in the main sidebar.
280 * 
281 * This function hooked into the micro_before_sidebar hook, 
282 * which is defined in /inc/hooks.php, and which fires
283 * in the sidebar.php template file.
284 * 
285 * Child Themes can remove this output by calling 
286 * remove_action( 'micro_before_sidebar', 'micro_close_upper', 200 );
287 * 
288 * Template file: sidebar.php
289 * 
290 * @param	none
291 * @return	string	HTML markup for sidebar site details container close tag
292 * 
293 * @since	Micro 1.0
294 * 
295 */
296function micro_close_upper(){
297
298	echo "</div>";
299
300}
301// Hook micro_close_upper() into micro_before_sidebar
302add_action( 'micro_before_sidebar', 'micro_close_upper', 200 );