Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 238 lines (176 sloc) 6.331 kb
8249a3b @saltcod First commit.
authored
1 <?php
2 /**
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
3 * A study in stuctural functionalism at Victoria Park
8249a3b @saltcod First commit.
authored
4 *
5 * @package WordPress
190c366 @saltcod Removed Toolbox references, changed to Victoria Park
authored
6 * @subpackage Victoria Park
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
7 * @since Victoria Park 0.2
8249a3b @saltcod First commit.
authored
8 */
04a5842 @saltcod Add enqueue scripts function to functions.php
authored
9
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
10
11 /**
12 * Setup defaults, register taxonomies/post types and other WordPress features.
13 * This function is hooked into the after_setup_theme hook.
14 *
15 * @since Victoria Park 0.2
16 */
17
18 add_action('after_setup_theme', 'victoria_park_theme_setup');
19
20 function victoria_park_theme_setup(){
21 //add basic features
22 add_theme_support('automatic-feed-links');
23 add_theme_support('post-formats', array('aside', 'gallery'));
24
25 //add custom scripts
26 add_action('wp_enqueue_scripts', 'victoria_park_enqueue_scripts');
27
28 //add custom widgets/sidebars
29 add_action('init', 'victoria_park_widgets_init');
30
31 // add custom menus
32 add_action('init', 'victoria_park_register_menus');
33
34
35 // add various other custom actions/filters
36 add_filter('body_class', 'victoria_park_better_body_classes');
37 add_filter('wp_nav_menu', 'victoria_park_add_slug_class_to_menu_item');
38
39
40 //print template file in footer — remove for production.
41 add_action('wp_footer', 'victoria_park_show_template');
42
43 }
44
45
46 /**
47 * Loads theme-specific JavaScript files.
48 *
49 * @since 0.2
50 */
51
52 function victoria_park_enqueue_scripts() {
04a5842 @saltcod Add enqueue scripts function to functions.php
authored
53 wp_enqueue_script( 'jquery' );
8249a3b @saltcod First commit.
authored
54
04a5842 @saltcod Add enqueue scripts function to functions.php
authored
55 wp_register_script( 'victoriapark', get_template_directory_uri() .'/js/victoriapark.js');
56 wp_enqueue_script( 'victoriapark' );
57
58 }
59
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
60
04a5842 @saltcod Add enqueue scripts function to functions.php
authored
61
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
62 /**
63 * Include the page slug in the body class attribute.
64 *
65 * @since 0.2
66 *
67 * @param array $classes The existing classes for the body element
68 * @return array The amended class array for the body element
69 */
04a5842 @saltcod Add enqueue scripts function to functions.php
authored
70
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
71 function victoria_park_better_body_classes( $classes ){
b2af788 @saltcod Remove Javascript LESS compiling.
authored
72 global $post;
73 if ( isset( $post ) ) {
74 $classes[] = $post->post_type . '-' . $post->post_name;
75 }
76 return $classes;
77 }
78
79
80
e96e2a8 @saltcod Add the function to print the current template file being used to the…
authored
81
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
82 /**
83 * Print out the current template file to the footer.
84 * Obviously to be removed in production
85 *
86 * @since 0.2
87 */
e96e2a8 @saltcod Add the function to print the current template file being used to the…
authored
88
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
89 function victoria_park_show_template() {
e96e2a8 @saltcod Add the function to print the current template file being used to the…
authored
90 global $template;
602806d @saltcod add style.css and normalize.css, the right way this time
authored
91 echo '<strong>Template file:</strong>';
92 print_r($template);
e96e2a8 @saltcod Add the function to print the current template file being used to the…
authored
93 }
b32f8ca @saltcod tidy up the show_template in the footer
authored
94
e96e2a8 @saltcod Add the function to print the current template file being used to the…
authored
95
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
96
97 /**
98 * Add slug to menu li classes
99 *
100 * @since 0.2
101 */
102
103 function victoria_park_add_slug_class_to_menu_item($output){
fc5ecb9 @saltcod Function to add slug to menu li classes
authored
104 $ps = get_option('permalink_structure');
105 if(!empty($ps)){
106 $idstr = preg_match_all('/<li id="menu-item-(\d+)/', $output, $matches);
107 foreach($matches[1] as $mid){
108 $id = get_post_meta($mid, '_menu_item_object_id', true);
109 $slug = basename(get_permalink($id));
110 $output = preg_replace('/menu-item-'.$mid.'">/', 'menu-item-'.$mid.' menu-item-'.$slug.'">', $output, 1);
111 }
112 }
113 return $output;
114 }
115
8249a3b @saltcod First commit.
authored
116 /**
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
117 * This theme uses wp_nav_menu() in one location.
8249a3b @saltcod First commit.
authored
118 *
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
119 * @since 0.2
8249a3b @saltcod First commit.
authored
120 */
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
121
122
123 function victoria_park_register_menus(){
8249a3b @saltcod First commit.
authored
124 register_nav_menus( array(
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
125 'primary' => __( 'Primary Menu', 'victoria_park' ),
8249a3b @saltcod First commit.
authored
126 ) );
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
127
8249a3b @saltcod First commit.
authored
128 }
129
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
130
8249a3b @saltcod First commit.
authored
131 /**
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
132 * Modify the Posted on output
133 *
134 * @since 0.2
8249a3b @saltcod First commit.
authored
135 */
136
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
137 function victoria_park_posted_on() {
138 printf( __( '<span class="sep">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s" pubdate>%4$s</time></a><span class="byline"> </span></span>', 'toolbox' ),
139 esc_url( get_permalink() ),
140 esc_attr( get_the_time() ),
141 esc_attr( get_the_date( 'c' ) ),
142 esc_html( get_the_date() ),
143 esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
144 esc_attr( sprintf( __( 'View all posts by %s', 'toolbox' ), get_the_author() ) ),
145 esc_html( get_the_author() )
146 );
8249a3b @saltcod First commit.
authored
147 }
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
148
149
8249a3b @saltcod First commit.
authored
150
151 /**
152 * Register widgetized area and update sidebar with default widgets
153 */
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
154 function victoria_park_widgets_init() {
8249a3b @saltcod First commit.
authored
155 register_sidebar( array(
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
156 'name' => __( 'Sidebar 1', 'victoria_park' ),
8249a3b @saltcod First commit.
authored
157 'id' => 'sidebar-1',
158 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
159 'after_widget' => "</aside>",
160 'before_title' => '<h1 class="widget-title">',
161 'after_title' => '</h1>',
162 ) );
163
164 register_sidebar( array(
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
165 'name' => __( 'Sidebar 2', 'victoria_park' ),
8249a3b @saltcod First commit.
authored
166 'id' => 'sidebar-2',
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
167 'description' => __( 'An optional second sidebar area', 'victoria_park' ),
8249a3b @saltcod First commit.
authored
168 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
169 'after_widget' => "</aside>",
170 'before_title' => '<h1 class="widget-title">',
171 'after_title' => '</h1>',
172 ) );
173 }
174
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
175
176
177
178 if ( ! function_exists( 'victoria_park_content_nav' ) ):
8249a3b @saltcod First commit.
authored
179 /**
180 * Display navigation to next/previous pages when applicable
181 *
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
182 * @since victoria_park 1.2
8249a3b @saltcod First commit.
authored
183 */
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
184 function victoria_park_content_nav( $nav_id ) {
8249a3b @saltcod First commit.
authored
185 global $wp_query;
186
187 ?>
188 <nav id="<?php echo $nav_id; ?>">
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
189 <h1 class="assistive-text section-heading"><?php _e( 'Post navigation', 'victoria_park' ); ?></h1>
8249a3b @saltcod First commit.
authored
190
191 <?php if ( is_single() ) : // navigation links for single posts ?>
192
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
193 <?php previous_post_link( '<div class="nav-previous">%link</div>', '<span class="meta-nav">' . _x( '&larr;', 'Previous post link', 'victoria_park' ) . '</span> %title' ); ?>
194 <?php next_post_link( '<div class="nav-next">%link</div>', '%title <span class="meta-nav">' . _x( '&rarr;', 'Next post link', 'victoria_park' ) . '</span>' ); ?>
8249a3b @saltcod First commit.
authored
195
196 <?php elseif ( $wp_query->max_num_pages > 1 && ( is_home() || is_archive() || is_search() ) ) : // navigation links for home, archive, and search pages ?>
197
198 <?php if ( get_next_posts_link() ) : ?>
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
199 <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'victoria_park' ) ); ?></div>
8249a3b @saltcod First commit.
authored
200 <?php endif; ?>
201
202 <?php if ( get_previous_posts_link() ) : ?>
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
203 <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'victoria_park' ) ); ?></div>
8249a3b @saltcod First commit.
authored
204 <?php endif; ?>
205
206 <?php endif; ?>
207
208 </nav><!-- #<?php echo $nav_id; ?> -->
209 <?php
210 }
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
211 endif; // victoria_park_content_nav
8249a3b @saltcod First commit.
authored
212
213
214
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
215 function victoria_park_categorized_blog() {
8249a3b @saltcod First commit.
authored
216 if ( false === ( $all_the_cool_cats = get_transient( 'all_the_cool_cats' ) ) ) {
217 // Create an array of all the categories that are attached to posts
218 $all_the_cool_cats = get_categories( array(
219 'hide_empty' => 1,
220 ) );
221
222 // Count the number of categories that are attached to the posts
223 $all_the_cool_cats = count( $all_the_cool_cats );
224
225 set_transient( 'all_the_cool_cats', $all_the_cool_cats );
226 }
227
228 if ( '1' != $all_the_cool_cats ) {
229 // This blog has more than 1 category so toolbox_categorized_blog should return true
230 return true;
231 } else {
232 // This blog has only 1 category so toolbox_categorized_blog should return false
233 return false;
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
234
8249a3b @saltcod First commit.
authored
235 }
236 }
237
009295d @saltcod Much needed organizing of functions file, w/ proper initialization. U…
authored
238
Something went wrong with that request. Please try again.