1
|
1 |
<?php |
|
2 |
|
|
3 |
/** |
|
4 |
* This is Malleable's functions.php file. |
|
5 |
* You should make edits and add additional code above this point. |
|
6 |
* Only change the functions below if you know what you're doing. |
|
7 |
*/ |
|
8 |
|
|
9 |
/********************************************************/ |
|
10 |
|
|
11 |
/* Constant paths. */ |
|
12 |
define( MALLEABLE, get_stylesheet_directory() ); |
|
13 |
define( MALLEABLE_URL, get_stylesheet_directory_uri() ); |
|
14 |
|
|
15 |
/* For localization. */ |
|
16 |
load_theme_textdomain( 'malleable', MALLEABLE ); |
|
17 |
|
|
18 |
/* Hybrid News theme settings. */ |
|
19 |
$malleable_settings = get_option( 'malleable_theme_settings' ); |
|
20 |
|
|
21 |
/* Include admin files. */ |
|
22 |
if ( is_admin() ) |
|
23 |
require_once( MALLEABLE . '/library/admin/theme-settings.php' ); |
|
24 |
|
|
25 |
/* Actions. */ |
|
26 |
add_action( 'hybrid_head', 'malleable_front_page_template' ); |
|
27 |
add_action( 'wp_head', 'malleable_remove_actions' ); |
|
28 |
add_action( 'hybrid_header', 'hybrid_search_form' ); |
|
29 |
add_action( 'hybrid_after_page_nav', 'malleable_cat_nav' ); |
|
30 |
add_action( 'hybrid_after_container', 'malleable_widget_container', 11 ); |
|
31 |
add_action( 'hybrid_after_single','malleable_author_box' ); |
|
32 |
add_action( 'hybrid_header', 'malleable_show_address', 11 ); |
|
33 |
add_action( 'hybrid_footer', 'malleable_show_address', 11 ); |
|
34 |
|
|
35 |
/* Filters. */ |
|
36 |
add_filter( 'hybrid_post_meta_boxes', 'malleable_post_meta_boxes' ); |
|
37 |
|
|
38 |
/** |
|
39 |
* Removes default Hybrid theme actions |
|
40 |
* |
|
41 |
* @since 0.1 |
|
42 |
*/ |
|
43 |
function malleable_remove_actions() { |
|
44 |
remove_action( 'hybrid_after_container', 'hybrid_get_primary' ); |
|
45 |
remove_action( 'hybrid_after_container', 'hybrid_get_secondary' ); |
|
46 |
remove_action( 'hybrid_before_content', 'hybrid_breadcrumb' ); |
|
47 |
} |
|
48 |
|
|
49 |
/** |
|
50 |
* Displays the category menu. |
|
51 |
* |
|
52 |
* @since 0.2 |
|
53 |
*/ |
|
54 |
function malleable_cat_nav() { |
|
55 |
|
|
56 |
$args = array( |
|
57 |
'style' => 'list', |
|
58 |
'hide_empty' => true, |
|
59 |
'use_desc_for_title' => false, |
|
60 |
'depth' => 4, |
|
61 |
'hierarchical' => true, |
|
62 |
'echo' => false, // Leave as is. |
|
63 |
'title_li' => false, // Leave as is. |
|
64 |
); |
|
65 |
|
|
66 |
echo "\n\t<div id='cat-navigation'>\n\t\t"; |
|
67 |
|
|
68 |
echo '<div id="cat-nav" class="cat-nav"><ul class="menu sf-menu">' . str_replace( array( "\t", "\n", "\r" ), '', wp_list_categories( $args ) ) . '</ul></div>'; |
|
69 |
|
|
70 |
echo '<div id="feed"><ul>'; |
|
71 |
echo '<li class="feed-url"><a href="' . get_bloginfo( 'rss2_url' ) . '" title="' . __('Subscribe to the feed', 'malleable') . '">' . __('Subscribe', 'malleable') . '</a></li>'; |
|
72 |
echo '</ul></div>'; |
|
73 |
|
|
74 |
echo "\n\t</div>\n"; |
|
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* Adds JavaScript and CSS to Front Page page template. |
|
79 |
* Also removes the breadcrumb menu. |
|
80 |
* |
|
81 |
* @since 0.1 |
|
82 |
*/ |
|
83 |
function malleable_front_page_template() { |
|
84 |
if ( is_page_template( 'front-page.php' ) ) : |
|
85 |
wp_enqueue_script( 'slider', MALLEABLE_URL . '/library/js/jquery.cycle.js', array( 'jquery' ), 0.1 ); |
|
86 |
wp_enqueue_script( 'slider-functions', MALLEABLE_URL . '/library/js/jquery.functions.js', array( 'jquery' ), 0.1 ); |
|
87 |
wp_enqueue_style( 'front-page', MALLEABLE_URL . '/front-page.css', false, '0.1', 'screen' ); |
|
88 |
remove_action( 'hybrid_before_content', 'hybrid_breadcrumb' ); |
|
89 |
endif; |
|
90 |
} |
|
91 |
|
|
92 |
/** |
|
93 |
* Wraps the Primary, Secondary, and Tertiary widget sections. |
|
94 |
* |
|
95 |
* @since 0.1 |
|
96 |
*/ |
|
97 |
function malleable_widget_container() { |
|
98 |
if ( is_active_sidebar( 'primary' ) || is_active_sidebar( 'secondary' ) || is_active_sidebar( 'tertiary' ) ) : |
|
99 |
echo '<div id="widget-container">'; |
|
100 |
hybrid_get_primary(); |
|
101 |
hybrid_get_secondary(); |
|
102 |
echo '</div>'; |
|
103 |
endif; |
|
104 |
} |
|
105 |
|
|
106 |
/** |
|
107 |
* Shows an author description after the post. |
|
108 |
* Only shows on single post. |
|
109 |
* |
|
110 |
* @since 0.1 |
|
111 |
*/ |
|
112 |
function malleable_author_box() { |
|
113 |
global $hybrid_settings; |
|
114 |
?> |
|
115 |
<div class="author-profile vcard"> |
|
116 |
<?php echo get_avatar( get_the_author_email(), '96', $hybrid_settings['default_avatar'] ); ?> |
|
117 |
<h4 class="author-name fn n"><?php the_author_posts_link(); ?></h4> |
|
118 |
<p class="author-description author-bio"> |
|
119 |
<?php the_author_description(); ?> |
|
120 |
</p> |
|
121 |
</div> |
|
122 |
<?php |
|
123 |
} |
|
124 |
|
|
125 |
/** |
|
126 |
* Add additional post meta boxes. |
|
127 |
* - Feature image input box. |
|
128 |
* |
|
129 |
* @since 0.1 |
|
130 |
*/ |
|
131 |
function malleable_post_meta_boxes( $meta_boxes ) { |
|
132 |
$meta_boxes['medium'] = array( 'name' => 'Medium', 'default' => '', 'title' => __('Medium/Feature:', 'malleable'), 'type' => 'text', 'show_description' => false, 'description' => false ); |
|
133 |
return $meta_boxes; |
|
134 |
} |
|
135 |
|
|
136 |
function malleable_show_address(){ |
|
137 |
global $malleable_settings; |
|
138 |
if ( $malleable_settings['general_address'] == "yes" ) { |
|
139 |
echo '<div class="address vcard">'; |
|
140 |
echo '<div class="fn n org">'. get_bloginfo('title') .'</div>'; |
|
141 |
echo '<div class="adr">'; |
|
142 |
echo '<span class="street-address">'. $malleable_settings['general_address_street']. '</span>, '; |
|
143 |
echo '<span class="locality">'. $malleable_settings['general_address_city']. '</span>, '; |
|
144 |
echo '<span class="region">'. $malleable_settings['general_address_state']. '</span>, '; |
|
145 |
echo '<span class="postal-code">'. $malleable_settings['general_address_zip']. '</span> -- '; |
|
146 |
echo '<span class="tel">'. $malleable_settings['general_address_phone']. '</span>'; |
|
147 |
echo '</div>'; |
|
148 |
echo '</div>'; |
|
149 |
} |
|
150 |
} |
|
151 |
|
|
152 |
?> |