Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 444 lines (388 sloc) 13.523 kb
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
1 <?php
2 require_once 'admin/frank-theme-options.php';
3
4 add_action( 'after_setup_theme', 'frank_theme_setup' );
5
6 function frank_theme_setup(){
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
7 load_theme_textdomain( 'frank_theme', get_template_directory() . '/languages' );
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
8 }
9
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
10 if ( ! function_exists( 'frank_get_option' ) ) {
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
11 function frank_get_option( $key ) {
12
13 $frank_options = get_option( '_frank_options' );
14
15 /* Define the array of defaults */
16 $defaults = array(
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
17 'header' => '',
18 'footer' => '',
19 'tweet_post_button' => false,
20 'tweet_post_attribution' => '',
21 'sections' => array(
a983e9f @somerandomdude Fixed language directory placement
authored
22 'display_type' => 'default_loop',
23 'header' => false,
24 'title' => '',
25 'caption' => '',
26 'num_posts' => 10,
27 'categories' => array(),
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
28 'default' => true,
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
29 )
30 );
31
32 $frank_options = wp_parse_args( $frank_options, $defaults );
33
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
34 if ( isset( $frank_options[ $key ] ) )
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
35 return $frank_options[ $key ];
36
37 return false;
38 }
39 }
40
41 if ( ! isset( $content_width ) ) $content_width = 980;
42
43 define( 'HEADER_TEXTCOLOR', '3D302F' );
44 define( 'HEADER_IMAGE', '%s/images/default_header.jpg' );
45 define( 'HEADER_IMAGE_WIDTH', 980 );
46 define( 'HEADER_IMAGE_HEIGHT', 225 );
47
48 add_filter( 'wp_list_categories', 'frank_remove_category_list_rel' );
49 add_filter( 'the_category', 'frank_remove_category_list_rel' );
50 add_filter( 'dynamic_sidebar_params','frank_widget_first_last_classes' );
51
52 if ( frank_get_option( 'remove_script_version' ) ){
53 add_filter( 'script_loader_src', 'frank_remove_version_url_parameter', 15, 1 );
54 }
55 if ( frank_get_option( 'remove_style_version' ) ){
56 add_filter( 'style_loader_src', 'frank_remove_version_url_parameter', 15, 1 );
57 }
58 if ( frank_get_option( 'remove_wordpress_version' ) ){
59 add_filter( 'the_generator', 'frank_wp_generator' );
60 }
61
62 if ( ! is_admin() ) {
63 add_action( 'init', 'frank_enqueue_styles' );
64 }
65 if ( is_admin() ) {
66 add_action( 'init', 'frank_admin_assets' );
67 }
68
69 add_action( 'admin_menu', 'frank_admin_menu' );
70 add_action( 'wp_footer', 'frank_footer' );
71 add_action( 'wp_head', 'frank_header' );
72 add_action( 'widgets_init', 'frank_widgets' );
73 add_action( 'wp_head', 'frank_add_ie_js_fixes' );
74 add_action( 'after_setup_theme', 'frank_register_menu' );
75 add_action( 'after_switch_theme', 'frank_set_missing_widget_options' );
76
77 add_editor_style();
78
79 $custom_header_support = array(
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
80 'default-text-color' => '3D302F',
81 'flex-height' => true,
82 'wp-head-callback' => 'frank_header_style',
83 'admin-head-callback' => 'frank_admin_header_style',
84 'admin-preview-callback' => 'frank_admin_header_image',
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
85 );
86
87 add_theme_support( 'custom-header', $custom_header_support );
88 add_theme_support( 'automatic-feed-links' );
89 add_theme_support( 'post-thumbnails' );
90 add_theme_support( 'custom-background', array( 'default-color' => 'fffefe' ) );
91
92 add_image_size( 'post-image', 535, 9999 );
93 add_image_size( 'featured-image', 980, 200, true );
94 add_image_size( 'excerpt-image', 724, 160, true );
95 add_image_size( 'default-thumbnail', 535, 200, true );
96 add_image_size( 'two-up-thumbnail', 468, 200, true );
97 add_image_size( 'three-up-thumbnail', 297, 150, true );
98 add_image_size( 'four-up-thumbnail', 212, 100, true );
99
100 function frank_register_menu() {
101 register_nav_menu( 'frank_primary_navigation', 'Primary Navigation' );
102 }
103
104 function frank_widgets() {
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
105 register_sidebar(
106 array(
107 'name' => 'Sub Header',
108 'id' => 'widget-subheader',
109 'before_widget' => '<div id="%1$s" class="widget %2$s four columns">',
110 'after_widget' => '</div>',
111 'before_title' => '<h3 class="widget-title">',
112 'after_title' => '</h3>',
113 )
114 );
115
116 register_sidebar(
117 array(
118 'name' => 'Navigation',
119 'before_widget' => '<div id="%1$s" class="widget %2$s">',
120 'after_widget' => '</div>',
121 'before_title' => '<h3 class="widget-title">',
122 'after_title' => '</h3>',
123 )
124 );
125
126 register_sidebar(
127 array(
128 'name' => 'Index Right Aside',
129 'before_widget' => '<div id="%1$s" class="widget %2$s">',
130 'after_widget' => '</div>',
131 'before_title' => '<h3 class="widget-title">',
132 'after_title' => '</h3>',
133 )
134 );
135
136 register_sidebar(
137 array(
138 'name' => 'Post Left Aside',
139 'before_widget' => '<div id="%1$s" class="widget %2$s">',
140 'after_widget' => '</div>',
141 'before_title' => '<h3 class="widget-title">',
142 'after_title' => '</h3>',
143 )
144 );
145
146 register_sidebar(
147 array(
148 'name' => 'Post Right Aside',
149 'before_widget' => '<div id="%1$s" class="widget %2$s">',
150 'after_widget' => '</div>',
151 'before_title' => '<h3 class="widget-title">',
152 'after_title' => '</h3>',
153 )
154 );
155
156 register_sidebar(
157 array(
158 'name' => 'Post Footer',
159 'id' => 'widget-postfooter',
160 'before_widget' => '<div id="%1$s" class="widget %2$s four columns">',
161 'after_widget' => '</div>',
162 'before_title' => '<h3 class="widget-title">',
163 'after_title' => '</h3>',
164 )
165 );
166
167 register_sidebar(
168 array(
169 'name' => 'Footer',
170 'id' => 'widget-footer',
171 'before_widget' => '<div id="%1$s" class="widget %2$s six columns">',
172 'after_widget' => '</div>',
173 'before_title' => '<h3 class="widget-title">',
174 'after_title' => '</h3>',
175 )
176 );
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
177 }
178
179 /*
180 Clean up widget settings that weren't set at installation
181 If never used in a sidebar, their lack of default options will
182 trigger queries every page load
183 */
184 function frank_set_missing_widget_options( ){
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
185 add_option( 'widget_pages', array( '_multiwidget' => 1 ) );
186 add_option( 'widget_calendar', array( '_multiwidget' => 1 ) );
187 add_option( 'widget_tag_cloud', array( '_multiwidget' => 1 ) );
188 add_option( 'widget_nav_menu', array( '_multiwidget' => 1 ) );
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
189 }
190
191 function frank_remove_version_url_parameter( $src ) {
192 $parts = explode( '?', $src );
193 return $parts[0];
194 }
195
196 function frank_wp_generator() {
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
197 echo '<meta name="generator" content="WordPress ', bloginfo( 'version' ), '" />';
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
198 }
199
200 if ( ! function_exists( 'frank_header_style' ) ) :
201 function frank_header_style() {
202 $text_color = get_header_textcolor();
203
204 if ( $text_color == HEADER_TEXTCOLOR )
205 return;
206 ?>
207 <style type="text/css">
208 <?php
209 if ( 'blank' == $text_color ) :
210 ?>
211 #site-title-description {
212 position: absolute !important;
213 clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
214 clip: rect(1px, 1px, 1px, 1px);
215 }
216 <?php
217 else :
218 ?>
219 #site-title a,
220 #site-description {
221 color: #<?php echo $text_color; ?> !important;
222 }
223 <?php endif; ?>
224 </style>
225 <?php
226 }
227 endif;
228
229 if ( ! function_exists( 'frank_admin_header_style' ) ) :
230 function frank_admin_header_style() {
231 ?>
232 <style type="text/css">
233 .appearance_page_custom-header #headimg {
234 border: none;
235 }
236
237 #desc, h1 {
238 line-height: 1.25;
239 }
240 #headimg h1 {
241 font-family: "Helvetica Neue", Arial, Helvetica, "Nimbus Sans L", sans-serif;
242 font-size: 24px;
243 margin-bottom: 5px;
244 margin-top:15px;
245 font-weight: normal
246 }
247 #headimg h1 a {
248 color: #3D302F;
249 text-decoration: none
250 }
251 #desc {
252 margin-top: 0;
253 font-size: 13px;
254 margin-bottom: 15px
255 }
256 <?php
257 // If the user has set a custom color for the text use that
258 if ( get_header_textcolor() != HEADER_TEXTCOLOR ) :
259 ?>
260 #site-title a,
261 #site-description {
262 color: #<?php echo get_header_textcolor(); ?>;
263 }
264 <?php endif; ?>
265 #headimg img {
266 max-width: 980px;
267 height: auto;
268 width: 100%;
269 }
270 </style>
271 <?php
272 }
273 endif;
274
275 if ( ! function_exists( 'frank_admin_header_image' ) ) :
276 function frank_admin_header_image() { ?>
277 <div id="headimg">
278 <?php
279 $color = get_header_textcolor();
280 $image = get_header_image();
281 if ( $color && $color != 'blank' )
282 $style = ' style="color:#' . $color . '"';
283 else
284 $style = ' style="display:none"';
285 ?>
286 <h1><a id="name"<?php echo $style; ?> onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a></h1>
287 <div id="desc"<?php echo $style; ?>><?php bloginfo( 'description' ); ?></div>
288 <?php if ( $image ) : ?>
289 <img src="<?php echo esc_url( $image ); ?>" alt="" />
290 <?php endif; ?>
291 </div>
292 <?php }
293 endif;
294
295 /* Remove rel attribute from the category list - thanks Joseph
296 (http://josephleedy.me/blog/make-wordpress-category-list-valid-by-removing-rel-attribute/)!
297 */
298
299 function frank_remove_category_list_rel( $output ) {
300 $output = str_replace( ' rel="category tag"', '', $output );
301 return $output;
302 }
303
304 /*
305 Add "first" and "last" CSS classes to dynamic sidebar widgets. Also adds numeric index class for each widget (widget-1, widget-2, etc.)
306 via http://wordpress.org/support/topic/how-to-first-and-last-css-classes-for-sidebar-widgets
307 */
308
309 function frank_widget_first_last_classes( $params ) {
310 global $my_widget_num; // Global a counter array
311 $this_id = $params[0]['id']; // Get the id for the current sidebar we're processing
312 $arr_registered_widgets = wp_get_sidebars_widgets(); // Get an array of ALL registered widgets
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
313 // If the counter array doesn't exist, create it
314 if ( ! $my_widget_num ) {
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
315 $my_widget_num = array();
316 }
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
317 // Check if the current sidebar has no widgets
318 if ( ! isset( $arr_registered_widgets[$this_id] ) || ! is_array( $arr_registered_widgets[$this_id] ) ) {
319 // No widgets in this sidebar... bail early.
320 return $params;
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
321 }
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
322 // See if the counter array has an entry for this sidebar
323 if ( isset( $my_widget_num[$this_id] ) ) {
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
324 $my_widget_num[$this_id] ++;
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
325 }
326 // If not, create it starting with 1
327 else {
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
328 $my_widget_num[$this_id] = 1;
329 }
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
330 // Add a widget number class for additional styling options
331 $class = 'class="widget-' . $my_widget_num[$this_id] . ' ';
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
332
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
333 // If this is the first widget
334 if ( $my_widget_num[$this_id] == 1 ) {
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
335 $class .= 'widget-first ';
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
336 }
337 // If this is the last widget
338 elseif ( $my_widget_num[$this_id] == count( $arr_registered_widgets[$this_id] ) ) {
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
339 $class .= 'widget-last ';
340 }
341
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
342 // Insert our new classes into "before widget"
343 $params[0]['before_widget'] = str_replace( 'class="', $class, $params[0]['before_widget'] );
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
344
345 return $params;
346 }
347
348 // ======================
349 // = HOME PAGE SECTIONS =
350 // ======================
351
352 if ( ! function_exists( 'frank_theme_options' ) ) {
353 function frank_theme_options() {
354 frank_build_settings_page();
355 }
356 }
357
358 // add our menus
359 function frank_admin_menu() {
360 add_theme_page( 'Frank', __( 'Frank Theme Options', 'frank_theme' ), 'manage_options', 'frank-settings', 'frank_theme_options' );
361 }
362
363 function frank_admin_assets() {
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
364 wp_enqueue_style( 'frank-admin', get_template_directory_uri() . '/admin/stylesheets/frank-options.css', NULL, NULL, NULL );
365 wp_enqueue_script( 'jquery-ui-sortable' );
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
366 wp_enqueue_script( 'frank-admin', get_template_directory_uri() . '/admin/javascripts/frank-utils.js', 'jquery', NULL, true );
367 $translation_array = array();
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
368 $translation_array['delete_section_alert'] = __( 'Are you sure you want to delete this Content Section?', 'frank_theme' );
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
369 $translation_array['drag_section_instruction'] = '&larr; ' . __('(Drag & Drop Content Sections to Re-Order)', 'frank_theme' );
370 wp_localize_script( 'frank-admin', 'admin_strings', $translation_array );
371 }
372
373 function frank_footer() {
374 echo stripslashes( frank_get_option( 'footer' ) );
375 }
376
377 function frank_header() {
378 echo stripslashes( frank_get_option( 'header' ) );
379 }
380
381 function frank_tweet_post_button() {
382 if ( frank_get_option( 'tweet_post_button' ) ) return true;
383 }
384
385 function frank_tweet_post_attribution() {
386 return frank_get_option( 'tweet_post_attribution' );
387 }
388
389 if ( ! function_exists( 'frank_comment' ) ) {
390 function frank_comment( $comment, $args, $depth ) {
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
391 $GLOBALS['comment'] = $comment; ?>
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
392
393 <li id="comment-<?php comment_ID() ?>" class="comment">
394 <div class="row">
395 <div class="comment-content">
396 <?php
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
397 if ( $comment->comment_approved == '0' ) {
398 $moderation_pending = __( 'Your comment is awaiting moderation', 'frank_theme' );
399 echo '<span class="comment-moderation">' . $moderation_pending . '</span>';
400 }
401 comment_text();
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
402 ?>
403 <div class="comment-reply">
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
404 <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ) ?>
405 </div>
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
406 </div>
407 <div class="comment-info">
408 <ul class='metadata vertical'>
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
409 <li class="date"><time datetime="<?php the_time( 'Y-m-d' ); ?>"><span class="date-date"><?php comment_date( 'F d, Y' ); ?></span> <span class="date-time"><?php comment_date( 'g:i A' ); ?></span></time></li>
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
410 <li class='author' id="vcard-<?php comment_ID() ?>">
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
411 <?php
412 echo _x( 'By', 'comment_author_attribution', 'frank_theme' );
413 echo ' ';
414 ?>
415 <a class="url fn" href="<?php comment_author_url(); ?>"><?php comment_author(); ?></a></li>
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
416 <li>
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
417 <?php edit_comment_link( _x( 'edit', 'edit-comment', 'frank_theme' ) ); ?>
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
418 </li>
419 </ul>
420 </div>
421 </div>
422 <?php
423 }
424 }
425
426 if ( ! function_exists( 'frank_enqueue_styles' ) ) {
427 function frank_enqueue_styles() {
428 global $wp_styles;
429
430 wp_register_style( 'frank_stylesheet', get_stylesheet_directory_uri().'/style.css', null, '0.9', 'all' );
431 wp_register_style( 'frank_stylesheet_ie', get_stylesheet_directory_uri().'/ie.css', null, '0.9', 'all' );
432 $wp_styles->add_data( 'frank_stylesheet_ie', 'conditional', 'IE' );
433 wp_enqueue_style( 'frank_stylesheet' );
434 wp_enqueue_style( 'frank_stylesheet_ie' );
435 }
436 }
437
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
438 function frank_add_ie_js_fixes() {
439 echo '<!--[if lt IE 9]><script src="', get_stylesheet_directory_uri(), '/javascripts/html5.js"></script><![endif]-->';
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
440
ea6ce0b @somerandomdude Merging with 0.9.3 branch
authored
441 echo '<!--[if lt IE 7]><script src="', get_stylesheet_directory_uri(), '/javascripts/ie7.js"></script><![endif]-->';
3ec3642 @somerandomdude Moved all files from 'frank' into root directory. Removed 'somerandom…
authored
442 }
a70fd6a @firatakandere Update functions.php
firatakandere authored
443 ?>
Something went wrong with that request. Please try again.