Skip to content
Newer
Older
100644 741 lines (667 sloc) 26.5 KB
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
1 <?php
2 /**
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
3 * Formattd functions and definitions
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
4 *
5 * Sets up the theme and provides some helper functions. Some helper functions
6 * are used in the theme as custom template tags. Others are attached to action and
7 * filter hooks in WordPress to change core functionality.
8 *
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
9 * The first function, formattd_setup(), sets up the theme by registering support
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
10 * for various features in WordPress, such as post thumbnails, navigation menus, and the like.
11 *
12 * When using a child theme (see http://codex.wordpress.org/Theme_Development and
13 * http://codex.wordpress.org/Child_Themes), you can override certain functions
14 * (those wrapped in a function_exists() call) by defining them first in your child theme's
15 * functions.php file. The child theme's functions.php file is included before the parent
16 * theme's file, so the child theme functions would be used.
17 *
18 * Functions that are not pluggable (not wrapped in function_exists()) are instead attached
19 * to a filter or action hook. The hook can be removed by using remove_action() or
20 * remove_filter() and you can attach your own function to the hook.
21 *
22 * We can remove the parent theme's hook only after it is attached, which means we need to
23 * wait until setting up the child theme:
24 *
25 * <code>
26 * add_action( 'after_setup_theme', 'my_child_theme_setup' );
27 * function my_child_theme_setup() {
28 * // We are providing our own filter for excerpt_length (or using the unfiltered value)
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
29 * remove_filter( 'excerpt_length', 'formattd_excerpt_length' );
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
30 * ...
31 * }
32 * </code>
33 *
34 * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
35 *
36 * @package WordPress
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
37 * @subpackage Formattd
ad89bf4 Changing current version to 0.1. Meant to do this before uploading to…
Dougal Campbell authored Apr 29, 2011
38 * @since Formattd 0.1
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
39 */
40
41 /**
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
42 * In wp-includes/vars.php we set some user-agent variables.
43 * Let's be more specific about iPad vs iPhone:
44 */
171fe4d @dougalcampbell Eliminate PHP warning and also a WP warning about enqueing the CSS.
authored Sep 16, 2012
45 $is_ios = $is_ipod = $is_ipad = false;
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
46 if ( $is_iphone && stripos($_SERVER['HTTP_USER_AGENT'], 'ipad') !== false ) {
47 $is_ipad = true;
48 $is_iphone = false;
49 }
50
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
51 /* ...and iPod Touch... */
ca8dd7e Many improvements to mobile styling.
Dougal Campbell authored Apr 29, 2011
52 if ( $is_iphone && stripos($_SERVER['HTTP_USER_AGENT'], 'ipod') !== false ) {
53 $is_ipod = true;
54 $is_iphone = false;
55 }
56
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
57 /* ...they're all in the iOS family... */
ca8dd7e Many improvements to mobile styling.
Dougal Campbell authored Apr 29, 2011
58 if ( $is_iphone || $is_ipad || $is_ipod )
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
59 $is_ios = true;
60
0a4a31e @dougalcampbell Eliminate horizontal scroll bar. Hide certain admin bar areas for mob…
authored Mar 2, 2012
61 $formattd_css_version = '0.0.23';
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
62
63 /**
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
64 * Set the content width based on the theme's design and stylesheet.
65 *
66 * Used to set the width of images and content. Should be equal to the width the theme
67 * is designed for, generally via the style.css stylesheet.
68 */
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
69 if ( ! isset( $content_width ) ) {
70 $content_width = 480;
426f71d More mobile adjustments. Remove redundant stylesheet ref.
Dougal Campbell authored Apr 28, 2011
71 if ( $is_ios ) {
ca8dd7e Many improvements to mobile styling.
Dougal Campbell authored Apr 29, 2011
72 $content_width = 250; // for ios portrait orientation
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
73 }
74 }
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
75
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
76 /** Tell WordPress to run formattd_setup() when the 'after_setup_theme' hook is run. */
77 add_action( 'after_setup_theme', 'formattd_setup', 9 );
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
78
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
79 if ( ! function_exists( 'formattd_setup' ) ):
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
80 /**
81 * Sets up theme defaults and registers support for various WordPress features.
82 *
83 * Note that this function is hooked into the after_setup_theme hook, which runs
84 * before the init hook. The init hook is too late for some features, such as indicating
85 * support post thumbnails.
86 *
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
87 * To override formattd_setup() in a child theme, add your own formattd_setup to your child theme's
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
88 * functions.php file.
89 *
90 * @uses add_theme_support() To add support for post thumbnails and automatic feed links.
91 * @uses register_nav_menus() To add support for navigation menus.
92 * @uses add_custom_background() To add support for a custom background.
93 * @uses add_editor_style() To style the visual editor.
94 * @uses load_theme_textdomain() For translation/localization support.
95 * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
96 *
ad89bf4 Changing current version to 0.1. Meant to do this before uploading to…
Dougal Campbell authored Apr 29, 2011
97 * @since Formattd 0.1
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
98 */
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
99 function formattd_setup() {
d5d0787 Forgot to make the CSS version variable global so that it can be seen…
Dougal Campbell authored Apr 29, 2011
100 global $is_ios, $is_iphone, $is_ipad, $is_ipod, $formattd_css_version;
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
101 // This theme styles the visual editor with editor-style.css to match the theme style.
102 add_editor_style();
103
104 // Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories.
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
105 add_theme_support( 'post-formats', array( 'aside', 'link', 'image', 'video', 'quote', 'gallery', 'status', 'chat', 'audio' ) );
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
106
107 // This theme uses post thumbnails
108 add_theme_support( 'post-thumbnails' );
109
110 // Add default posts and comments RSS feed links to head
111 add_theme_support( 'automatic-feed-links' );
112
2c83125 Making progress
Dougal Campbell authored Apr 3, 2011
113 // Auto-add a float-right thumbnail featured image, when set
114 if (function_exists('set_post_thumbnail_size')) {
2811d68 Fix featured image adjust for iPhone/iPod Touch
Dougal Campbell authored Apr 29, 2011
115 if ($is_iphone || $is_ipod) {
426f71d More mobile adjustments. Remove redundant stylesheet ref.
Dougal Campbell authored Apr 29, 2011
116 set_post_thumbnail_size( 120, 120, true );
117 } else {
118 set_post_thumbnail_size( 240, 240, true );
119 }
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
120 }
121
122 if (function_exists('add_image_size')) {
123 add_image_size('thumbnail', 125, 125, true);
124 add_image_size('featured', 240, 240, true);
125 add_image_size('small', 125, 170);
126 add_image_size('medium', 240, 320);
127 add_image_size('large', 380, 512);
128 add_image_size('xlarge', 480, 640);
129 add_image_size('full', 9999, 9999);
2c83125 Making progress
Dougal Campbell authored Apr 3, 2011
130 }
131
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
132 add_filter('the_content', 'formattd_post_thumbnail');
2c83125 Making progress
Dougal Campbell authored Apr 3, 2011
133
134 // Make theme available for translation
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
135 // Translations can be filed in the /languages/ directory
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
136 load_theme_textdomain( 'formattd', TEMPLATEPATH . '/languages' );
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
137
138 $locale = get_locale();
139 $locale_file = TEMPLATEPATH . "/languages/$locale.php";
140 if ( is_readable( $locale_file ) )
141 require_once( $locale_file );
142
143 // This theme uses wp_nav_menu() in one location.
144 register_nav_menus( array(
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
145 'primary' => __( 'Primary Navigation', 'formattd' ),
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
146 ) );
147
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
148 // Add official.fm as an oembed provider:
149 wp_oembed_add_provider('http://official.fm/*', 'http://official.fm/services/oembed/');
e12966a proto dropdown menus. needs work.
Dougal Campbell authored Apr 19, 2011
150
171fe4d @dougalcampbell Eliminate PHP warning and also a WP warning about enqueing the CSS.
authored Sep 17, 2012
151 }
152 endif;
153
154 add_action('init', 'formattd_init', 9);
155
156 if (!function_exists('formattd_init')) :
157 function formattd_init() {
158 global $formattd_css_version;
159
e12966a proto dropdown menus. needs work.
Dougal Campbell authored Apr 20, 2011
160 // Dropdown menus
5b668ec Load dropdown js from template directory, not stylesheet directory.
Dougal Campbell authored Apr 29, 2011
161 wp_enqueue_script('dropdown', trailingslashit( get_template_directory_uri() ) . 'js/jquery.dropdownPlain.js', array('jquery'), '1.1');
c2be80d Mathias Bynens' iOS viewport scaling bugfix js.
Dougal Campbell authored May 4, 2011
162
163 // iOS scaling fix
164 wp_enqueue_script('ios-scaling', trailingslashit( get_template_directory_uri() ) . 'js/ios-scaling-bugfix.js', array(), '1.0');
171fe4d @dougalcampbell Eliminate PHP warning and also a WP warning about enqueing the CSS.
authored Sep 17, 2012
165
166 // Load main stylesheet
167 if (! is_admin() ) {
168 wp_enqueue_style( 'formattd', get_template_directory_uri() . '/style.css', array(), $formattd_css_version );
169 }
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
170 }
171 endif;
172
2c83125 Making progress
Dougal Campbell authored Apr 3, 2011
173 // Add X-UA-Compatible header in HTTP, not in HTML
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
174 if ( ! function_exists( 'formattd_redirect' ) ) :
175 function formattd_redirect() {
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
176 // Send as an HTTP header instead using meta http-equiv.
177 // See: http://lists.w3.org/Archives/Public/www-validator/2010Nov/0050.html
178 @header( 'X-UA-Compatible: IE=edge,chrome=1' );
179 }
180 endif;
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
181 add_action( 'template_redirect', 'formattd_redirect' );
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
182
183 /**
184 * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
185 *
186 * To override this in a child theme, remove the filter and optionally add
187 * your own function tied to the wp_page_menu_args filter hook.
188 *
ad89bf4 Changing current version to 0.1. Meant to do this before uploading to…
Dougal Campbell authored Apr 29, 2011
189 * @since Formattd 0.1
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
190 */
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
191 if (! function_exists('formattd_page_menu_args') ) :
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
192 function formattd_page_menu_args( $args ) {
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
193 $args['show_home'] = true;
194 return $args;
195 }
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
196 endif;
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
197 add_filter( 'wp_page_menu_args', 'formattd_page_menu_args' );
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
198
199 /**
2c83125 Making progress
Dougal Campbell authored Apr 3, 2011
200 * Sets the post excerpt length to 75 words.
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
201 *
2c83125 Making progress
Dougal Campbell authored Apr 3, 2011
202 * To override this length in a child theme, remove the filter and add your
203 * own function tied to the excerpt_length filter hook.
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
204 *
ad89bf4 Changing current version to 0.1. Meant to do this before uploading to…
Dougal Campbell authored Apr 29, 2011
205 * @since Formattd 0.1
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
206 * @return int
207 */
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
208 if (! function_exists('formattd_excerpt_length') ) :
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
209 function formattd_excerpt_length( $length ) {
2c83125 Making progress
Dougal Campbell authored Apr 3, 2011
210 return 75;
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
211 }
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
212 endif;
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
213 add_filter( 'excerpt_length', 'formattd_excerpt_length' );
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
214
215 /**
216 * Returns a "Continue Reading" link for excerpts
217 *
ad89bf4 Changing current version to 0.1. Meant to do this before uploading to…
Dougal Campbell authored Apr 29, 2011
218 * @since Formattd 0.1
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
219 * @return string "Continue Reading" link
220 */
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
221 if (! function_exists('formattd_continue_reading_link') ) :
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
222 function formattd_continue_reading_link() {
223 return ' <a href="'. get_permalink() . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'formattd' ) . '</a>';
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
224 }
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
225 endif;
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
226
227 /**
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
228 * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and formattd_continue_reading_link().
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
229 *
230 * To override this in a child theme, remove the filter and add your own
231 * function tied to the excerpt_more filter hook.
232 *
ad89bf4 Changing current version to 0.1. Meant to do this before uploading to…
Dougal Campbell authored Apr 29, 2011
233 * @since Formattd 0.1
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
234 * @return string An ellipsis
235 */
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
236 if (! function_exists('formattd_auto_excerpt_more') ) :
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
237 function formattd_auto_excerpt_more( $more ) {
0a4a31e @dougalcampbell Eliminate horizontal scroll bar. Hide certain admin bar areas for mob…
authored Mar 2, 2012
238 return ' &hellip; ' . formattd_continue_reading_link();
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
239 }
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
240 endif;
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
241 add_filter( 'excerpt_more', 'formattd_auto_excerpt_more' );
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
242
243 /**
244 * Adds a pretty "Continue Reading" link to custom post excerpts.
245 *
246 * To override this link in a child theme, remove the filter and add your own
247 * function tied to the get_the_excerpt filter hook.
248 *
ad89bf4 Changing current version to 0.1. Meant to do this before uploading to…
Dougal Campbell authored Apr 29, 2011
249 * @since Formattd 0.1
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
250 * @return string Excerpt with a pretty "Continue Reading" link
251 */
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
252 if (! function_exists('formattd_custom_excerpt_more') ) :
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
253 function formattd_custom_excerpt_more( $output ) {
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
254 if ( has_excerpt() && ! is_attachment() ) {
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
255 $output .= formattd_continue_reading_link();
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
256 }
257 return $output;
258 }
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
259 endif;
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
260 add_filter( 'get_the_excerpt', 'formattd_custom_excerpt_more' );
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
261
262 /**
263 * Remove inline styles printed when the gallery shortcode is used.
264 *
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
265 * Galleries are styled by the theme in Formattd's style.css. This is just
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
266 * a simple filter call that tells WordPress to not use the default styles.
267 *
773026b Improve sidebar link colors.
Dougal Campbell authored May 6, 2011
268 * @since Formattd 0.1
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
269 */
270 add_filter( 'use_default_gallery_style', '__return_false' );
271
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
272 if ( ! function_exists( 'formattd_comment' ) ) :
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
273 /**
274 * Template for comments and pingbacks.
275 *
276 * To override this walker in a child theme without modifying the comments template
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
277 * simply create your own formattd_comment(), and that function will be used instead.
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
278 *
279 * Used as a callback by wp_list_comments() for displaying the comments.
280 *
ad89bf4 Changing current version to 0.1. Meant to do this before uploading to…
Dougal Campbell authored Apr 29, 2011
281 * @since Formattd 0.1
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
282 */
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
283 function formattd_comment( $comment, $args, $depth ) {
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
284 $GLOBALS['comment'] = $comment;
58c22f5 Misc changes. Styling fixes. s/twentyten/initializr/
Dougal Campbell authored Apr 2, 2011
285 $GLOBALS['depth'] = $depth;
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
286 switch ( $comment->comment_type ) :
287 case '' :
773026b Improve sidebar link colors.
Dougal Campbell authored May 6, 2011
288 ?>
289 <!-- comment callback -->
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
290 <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
291 <div id="comment-<?php comment_ID(); ?>">
292 <div class="comment-author vcard">
293 <?php echo get_avatar( $comment, 40 ); ?>
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
294 <?php printf( __( '%s <span class="says">says:</span>', 'formattd' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
295 </div><!-- .comment-author .vcard -->
296 <?php if ( $comment->comment_approved == '0' ) : ?>
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
297 <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'formattd' ); ?></em>
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
298 <br />
299 <?php endif; ?>
300
301 <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
302 <?php
303 /* translators: 1: date, 2: time */
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
304 printf( __( '%1$s at %2$s', 'formattd' ), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'formattd' ), ' ' );
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
305 ?>
306 </div><!-- .comment-meta .commentmetadata -->
307
308 <div class="comment-body"><?php comment_text(); ?></div>
309
310 <div class="reply">
311 <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
312 </div><!-- .reply -->
313 </div><!-- #comment-## -->
314
315 <?php
316 break;
317 case 'pingback' :
318 case 'trackback' :
319 ?>
320 <li class="post pingback">
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
321 <p><?php _e( 'Pingback:', 'formattd' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'formattd' ), ' ' ); ?></p>
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
322 <?php
323 break;
324 endswitch;
325 }
326 endif;
327
328 /**
329 * Register widgetized areas, including two sidebars and four widget-ready columns in the footer.
330 *
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
331 * To override formattd_widgets_init() in a child theme, remove the action hook and add your own
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
332 * function tied to the init hook.
333 *
ad89bf4 Changing current version to 0.1. Meant to do this before uploading to…
Dougal Campbell authored Apr 29, 2011
334 * @since Formattd 0.1
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
335 * @uses register_sidebar
336 */
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
337 if (! function_exists('formattd_widgets_init') ) :
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
338 function formattd_widgets_init() {
cfacb21 widget area madness!
Dougal Campbell authored Apr 22, 2011
339 // Header widget area
340 register_sidebar( array(
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
341 'name' => __( 'Above Header Widget Area', 'formattd' ),
cfacb21 widget area madness!
Dougal Campbell authored Apr 22, 2011
342 'id' => 'above-header',
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
343 'description' => __( 'In the header, before site name', 'formattd' ),
cfacb21 widget area madness!
Dougal Campbell authored Apr 22, 2011
344 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
345 'after_widget' => '</li>',
346 'before_title' => '<h3 class="widget-title">',
347 'after_title' => '</h3>',
348 ) );
349
350 // Primary sidebar, located at the top of the sidebar.
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
351 register_sidebar( array(
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
352 'name' => __( 'Primary Widget Area', 'formattd' ),
d627aa2 rename primary widget area
Dougal Campbell authored Apr 22, 2011
353 'id' => 'primary-aside',
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
354 'description' => __( 'The primary widget area', 'formattd' ),
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
355 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
356 'after_widget' => '</li>',
357 'before_title' => '<h3 class="widget-title">',
358 'after_title' => '</h3>',
359 ) );
360
cfacb21 widget area madness!
Dougal Campbell authored Apr 22, 2011
361 // Secondary sidebar, located below the Primary Widget Area in the sidebar. Empty by default.
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
362 register_sidebar( array(
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
363 'name' => __( 'Secondary Widget Area', 'formattd' ),
2f6ce98 add index-top widget area
Dougal Campbell authored Apr 22, 2011
364 'id' => 'secondary-aside',
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
365 'description' => __( 'The secondary widget area', 'formattd' ),
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
366 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
367 'after_widget' => '</li>',
368 'before_title' => '<h3 class="widget-title">',
369 'after_title' => '</h3>',
370 ) );
371
2f6ce98 add index-top widget area
Dougal Campbell authored Apr 22, 2011
372 // Top of the content area. Empty by default.
373 register_sidebar( array(
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
374 'name' => __( 'Index Top Widget Area', 'formattd' ),
2f6ce98 add index-top widget area
Dougal Campbell authored Apr 22, 2011
375 'id' => 'index-top',
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
376 'description' => __( 'Appears between header and content on index and single post pages.', 'formattd' ),
2f6ce98 add index-top widget area
Dougal Campbell authored Apr 22, 2011
377 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
378 'after_widget' => '</li>',
379 'before_title' => '<h3 class="widget-title">',
380 'after_title' => '</h3>',
381 ) );
382
cfacb21 widget area madness!
Dougal Campbell authored Apr 22, 2011
383 // Top of the content area. Empty by default.
384 register_sidebar( array(
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
385 'name' => __( 'Index Insert Widget Area', 'formattd' ),
cfacb21 widget area madness!
Dougal Campbell authored Apr 22, 2011
386 'id' => 'index-insert',
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
387 'description' => __( 'Appears between 1st and 2nd post on index page.', 'formattd' ),
cfacb21 widget area madness!
Dougal Campbell authored Apr 22, 2011
388 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
389 'after_widget' => '</li>',
390 'before_title' => '<h3 class="widget-title">',
391 'after_title' => '</h3>',
392 ) );
393
394 // Top of the content area. Empty by default.
395 register_sidebar( array(
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
396 'name' => __( 'Index Bottom Widget Area', 'formattd' ),
cfacb21 widget area madness!
Dougal Campbell authored Apr 22, 2011
397 'id' => 'index-bottom',
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
398 'description' => __( 'Appears below posts on index page.', 'formattd' ),
cfacb21 widget area madness!
Dougal Campbell authored Apr 22, 2011
399 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
400 'after_widget' => '</li>',
401 'before_title' => '<h3 class="widget-title">',
402 'after_title' => '</h3>',
403 ) );
404
405 // Top of the content area. Empty by default.
406 register_sidebar( array(
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
407 'name' => __( 'Single Top Widget Area', 'formattd' ),
cfacb21 widget area madness!
Dougal Campbell authored Apr 22, 2011
408 'id' => 'single-top',
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
409 'description' => __( 'Appears between header and content on single post pages.', 'formattd' ),
cfacb21 widget area madness!
Dougal Campbell authored Apr 22, 2011
410 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
411 'after_widget' => '</li>',
412 'before_title' => '<h3 class="widget-title">',
413 'after_title' => '</h3>',
414 ) );
415
416 // Top of the content area. Empty by default.
417 register_sidebar( array(
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
418 'name' => __( 'Single Bottom Widget Area', 'formattd' ),
cfacb21 widget area madness!
Dougal Campbell authored Apr 22, 2011
419 'id' => 'single-bottom',
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
420 'description' => __( 'Appears below posts on single pages.', 'formattd' ),
cfacb21 widget area madness!
Dougal Campbell authored Apr 22, 2011
421 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
422 'after_widget' => '</li>',
423 'before_title' => '<h3 class="widget-title">',
424 'after_title' => '</h3>',
425 ) );
426
427 // Top of the content area. Empty by default.
428 register_sidebar( array(
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
429 'name' => __( 'Page Top Widget Area', 'formattd' ),
cfacb21 widget area madness!
Dougal Campbell authored Apr 22, 2011
430 'id' => 'page-top',
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
431 'description' => __( 'Appears between header and content on pages.', 'formattd' ),
cfacb21 widget area madness!
Dougal Campbell authored Apr 22, 2011
432 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
433 'after_widget' => '</li>',
434 'before_title' => '<h3 class="widget-title">',
435 'after_title' => '</h3>',
436 ) );
437
438 // Top of the content area. Empty by default.
439 register_sidebar( array(
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
440 'name' => __( 'Page Bottom Widget Area', 'formattd' ),
cfacb21 widget area madness!
Dougal Campbell authored Apr 22, 2011
441 'id' => 'Page-bottom',
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
442 'description' => __( 'Appears below posts on pages.', 'formattd' ),
cfacb21 widget area madness!
Dougal Campbell authored Apr 22, 2011
443 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
444 'after_widget' => '</li>',
445 'before_title' => '<h3 class="widget-title">',
446 'after_title' => '</h3>',
447 ) );
448
449 // Footer 1, located in the footer. Empty by default.
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
450 register_sidebar( array(
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
451 'name' => __( 'First Footer Widget Area', 'formattd' ),
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
452 'id' => 'first-footer-widget-area',
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
453 'description' => __( 'The first footer widget area', 'formattd' ),
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
454 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
455 'after_widget' => '</li>',
456 'before_title' => '<h3 class="widget-title">',
457 'after_title' => '</h3>',
458 ) );
459
cfacb21 widget area madness!
Dougal Campbell authored Apr 22, 2011
460 // Footer 2, located in the footer. Empty by default.
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
461 register_sidebar( array(
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
462 'name' => __( 'Second Footer Widget Area', 'formattd' ),
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
463 'id' => 'second-footer-widget-area',
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
464 'description' => __( 'The second footer widget area', 'formattd' ),
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
465 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
466 'after_widget' => '</li>',
467 'before_title' => '<h3 class="widget-title">',
468 'after_title' => '</h3>',
469 ) );
470
cfacb21 widget area madness!
Dougal Campbell authored Apr 22, 2011
471 // Footer 3, located in the footer. Empty by default.
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
472 register_sidebar( array(
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
473 'name' => __( 'Third Footer Widget Area', 'formattd' ),
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
474 'id' => 'third-footer-widget-area',
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
475 'description' => __( 'The third footer widget area', 'formattd' ),
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
476 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
477 'after_widget' => '</li>',
478 'before_title' => '<h3 class="widget-title">',
479 'after_title' => '</h3>',
480 ) );
481
cfacb21 widget area madness!
Dougal Campbell authored Apr 22, 2011
482 // Footer 4, located in the footer. Empty by default.
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
483 register_sidebar( array(
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
484 'name' => __( 'Fourth Footer Widget Area', 'formattd' ),
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
485 'id' => 'fourth-footer-widget-area',
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
486 'description' => __( 'The fourth footer widget area', 'formattd' ),
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
487 'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
488 'after_widget' => '</li>',
489 'before_title' => '<h3 class="widget-title">',
490 'after_title' => '</h3>',
491 ) );
492 }
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
493 endif;
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
494 /** Register sidebars by running formattd_widgets_init() on the widgets_init hook. */
495 add_action( 'widgets_init', 'formattd_widgets_init' );
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
496
497 /**
498 * Removes the default styles that are packaged with the Recent Comments widget.
499 *
2c83125 Making progress
Dougal Campbell authored Apr 3, 2011
500 * To override this in a child theme, remove the filter and optionally add
501 * your own function tied to the widgets_init action hook.
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
502 *
2c83125 Making progress
Dougal Campbell authored Apr 3, 2011
503 * This function uses a filter (show_recent_comments_widget_style) new in
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
504 * WordPress 3.1 to remove the default style. Using Formattd 1.2 in
2c83125 Making progress
Dougal Campbell authored Apr 3, 2011
505 * WordPress 3.0 will show the styles, but they won't have any effect on the
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
506 * widget in default Formattd styling.
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
507 *
ad89bf4 Changing current version to 0.1. Meant to do this before uploading to…
Dougal Campbell authored Apr 29, 2011
508 * @since Formattd 0.1
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
509 */
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
510 if (! function_exists('formattd_remove_recent_comments_style') ) :
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
511 function formattd_remove_recent_comments_style() {
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
512 add_filter( 'show_recent_comments_widget_style', '__return_false' );
513 }
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
514 endif;
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
515 add_action( 'widgets_init', 'formattd_remove_recent_comments_style' );
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
516
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
517 if ( ! function_exists( 'formattd_posted_on' ) ) :
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
518 /**
519 * Prints HTML with meta information for the current post-date/time and author.
520 *
ad89bf4 Changing current version to 0.1. Meant to do this before uploading to…
Dougal Campbell authored Apr 29, 2011
521 * @since Formattd 0.1
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
522 */
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
523 function formattd_posted_on() {
524 printf( __( '<span class="%1$s">Posted on</span> %2$s <span class="meta-sep">by</span> %3$s', 'formattd' ),
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
525 'meta-prep meta-prep-author',
526 sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
527 get_permalink(),
528 esc_attr( get_the_time() ),
529 get_the_date()
530 ),
b72b619 @dougalcampbell More author vcard happiness.
authored Jul 8, 2011
531 sprintf( '<span class="author vcard"><a class="url fn n" rel="author" href="%1$s" title="%2$s">%3$s</a></span>',
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
532 get_author_posts_url( get_the_author_meta( 'ID' ) ),
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
533 sprintf( esc_attr__( 'View all posts by %s', 'formattd' ), get_the_author() ),
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
534 get_the_author()
535 )
536 );
537 }
538 endif;
539
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
540 if ( ! function_exists( 'formattd_posted_in' ) ) :
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
541 /**
542 * Prints HTML with meta information for the current post (category, tags and permalink).
543 *
ad89bf4 Changing current version to 0.1. Meant to do this before uploading to…
Dougal Campbell authored Apr 29, 2011
544 * @since Formattd 0.1
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
545 */
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
546 function formattd_posted_in() {
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
547 // Retrieves tag list of current post, separated by commas.
548 $tag_list = get_the_tag_list( '', ', ' );
549 if ( $tag_list ) {
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
550 $posted_in = __( 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'formattd' );
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
551 } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
552 $posted_in = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'formattd' );
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
553 } else {
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
554 $posted_in = __( 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'formattd' );
2e4fc22 Initial commit. Bare bones.
Dougal Campbell authored Apr 1, 2011
555 }
556 // Prints the string, replacing the placeholders.
557 printf(
558 $posted_in,
559 get_the_category_list( ', ' ),
560 $tag_list,
561 get_permalink(),
562 the_title_attribute( 'echo=0' )
563 );
564 }
565 endif;
58c22f5 Misc changes. Styling fixes. s/twentyten/initializr/
Dougal Campbell authored Apr 2, 2011
566
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
567 if ( ! function_exists( 'formattd_post_date' ) ) :
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
568 /**
569 * Generates the calendar-style dates which hang in the left margin.
570 */
6f21dc3 Renaming from 'initializr' to 'formattd'.
Dougal Campbell authored Apr 24, 2011
571 function formattd_post_date() {
58c22f5 Misc changes. Styling fixes. s/twentyten/initializr/
Dougal Campbell authored Apr 2, 2011
572 $mon = get_the_time('M');
573 $day = get_the_time('d');
574 $year = get_the_time('Y');
575
576 printf('<div class="post-date"><span class="month">%s</span><span class="day">%s</span><span class="year">%s</span></div>', $mon, $day, $year);
577 }
578 endif;
579
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
580 if (! function_exists('formattd_post_thumbnail') ) :
581 /**
582 * Utility filter to inject post thumbnails into posts.
583 */
584 function formattd_post_thumbnail($text) {
2c83125 Making progress
Dougal Campbell authored Apr 3, 2011
585 if (function_exists('has_post_thumbnail') && has_post_thumbnail() /* && (is_home() || is_singular()) */) {
c203ae9 More tweakage.
Dougal Campbell authored Apr 3, 2011
586 $text = '<div class="featured-image align-right" style="float: right;">' . get_the_post_thumbnail() . '</div>' . $text;
2c83125 Making progress
Dougal Campbell authored Apr 3, 2011
587 }
588
589 return $text;
590 }
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
591 endif;
2c83125 Making progress
Dougal Campbell authored Apr 3, 2011
592
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
593 if (! function_exists('formattd_extract_first_link') ) :
0a4a31e @dougalcampbell Eliminate horizontal scroll bar. Hide certain admin bar areas for mob…
authored Mar 2, 2012
594 /**
2c83125 Making progress
Dougal Campbell authored Apr 3, 2011
595 * Extract the title and url for a post object for a 'link' post format.
596 */
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
597 function formattd_extract_first_link($post) {
2c83125 Making progress
Dougal Campbell authored Apr 3, 2011
598 $str = $post->post_content;
599 if ( preg_match('%^(https?://[^\s]*)$%', trim($str), $matches) ) {
600 $url = $matches[1];
601 if ($post->post_title) {
602 $title = $post->post_title;
603 } else {
604 $title = $url;
605 }
606 return array('url' => $url, 'title' => $title );
607 }
608
609 preg_match('%<a\s*+(.*?)href=(["\']?)(.*?)\2(.*?)>(.*?)</a>%', trim($str), $matches);
610 $url = $matches[3];
611 $title = $post->post_title ? $post->post_title : $matches[5];
612
613 return array( 'url' => $url, 'title' => $title );
614 }
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
615 endif;
2c83125 Making progress
Dougal Campbell authored Apr 3, 2011
616
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
617 if (! function_exists('formattd_time_ago') ) :
ccf78fa Fix post timestamps. Was using incorrect method to fetch GMT time of
Dougal Campbell authored May 11, 2011
618 function formattd_time_ago($timestamp=0, $granularity=2, $format='Y-m-d H:i:s') {
2c83125 Making progress
Dougal Campbell authored Apr 3, 2011
619 if ( 0 === $timestamp ) {
ccf78fa Fix post timestamps. Was using incorrect method to fetch GMT time of
Dougal Campbell authored May 11, 2011
620 // fetch the post time in UTC
621 $timestamp = get_post_time('U', true);
2c83125 Making progress
Dougal Campbell authored Apr 3, 2011
622 }
ccf78fa Fix post timestamps. Was using incorrect method to fetch GMT time of
Dougal Campbell authored May 11, 2011
623
2c83125 Making progress
Dougal Campbell authored Apr 3, 2011
624 $difference = time() - $timestamp;
9c4bc4c @dougalcampbell Fix some hfeed microformat bits.
authored Jul 7, 2011
625 if($difference < 0) return sprintf( '<span class="timestamp updated" title="%s">%s</span>', esc_attr(date('c', $timestamp)), 'Not yet...') ;
2c83125 Making progress
Dougal Campbell authored Apr 3, 2011
626 elseif($difference < 31536000){
ccf78fa Fix post timestamps. Was using incorrect method to fetch GMT time of
Dougal Campbell authored May 11, 2011
627 $periods = array('mon' => 2592000, 'wk' => 604800,'day' => 86400,'hr' => 3600,'min' => 60 );
2c83125 Making progress
Dougal Campbell authored Apr 3, 2011
628 $output = '';
629 foreach($periods as $key => $value){
630 if($difference >= $value){
631 $time = round($difference / $value);
632 $difference %= $value;
633 $output .= ($output ? ' ' : '').$time.' ';
634 $output .= (($time > 1 /* && $key == 'day' */) ? $key.'s' : $key);
635 $granularity--;
636 }
637 if($granularity == 0) break;
638 }
ccf78fa Fix post timestamps. Was using incorrect method to fetch GMT time of
Dougal Campbell authored May 11, 2011
639 $output = ($output ? $output : 'Just now').' ago';
9c4bc4c @dougalcampbell Fix some hfeed microformat bits.
authored Jul 8, 2011
640 return sprintf('<span class="timestamp updated" title="%s">%s</span>', esc_attr(date('c',$timestamp)) ,$output);
2c83125 Making progress
Dougal Campbell authored Apr 3, 2011
641 }
9c4bc4c @dougalcampbell Fix some hfeed microformat bits.
authored Jul 8, 2011
642 else return sprintf( '<span class="timestamp updated" title="%s">%s</span>', esc_attr(date('c', $timestamp)), date($format, $timestamp) );
2c83125 Making progress
Dougal Campbell authored Apr 3, 2011
643 }
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
644 endif;
2c83125 Making progress
Dougal Campbell authored Apr 3, 2011
645
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
646 if (! function_exists('formattd_process_chat') ) :
647 /**
648 * Auto-bold names in chat posts
649 */
650 function formattd_process_chat( $content ) {
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
651 if (has_post_format('chat')) {
652 $content = preg_replace('%<p>\s*([^:]+):(\s.*)</p>%e', '\'<p class="chat"><span class="person person-\'.sanitize_title(\'\\1\').\'">\\1:</span>\\2</p>\'', $content);
653 }
654 return $content;
655 }
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
656 endif;
657 // Run after WP html formatting
658 add_filter('the_content', 'formattd_process_chat', 15);
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
659
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
660
661 if (! function_exists('formattd_post_format_detect') ) :
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
662 /**
663 * If a post comes from XML-RPC or APP, try to detect and set the post
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
664 * format. There is currently not a good single filter or action hook
665 * to make this easy. So we cheat. We use the wp_insert_post_data filter
666 * to detect the format, and also to strip out the sentinel string. At
667 * that time, we set a global flag containing the detected format.
668 *
669 * Then, we tell the wp_insert_post action hook to use that flag to
670 * actually set the post format accordingly.
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
671 */
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
672 function formattd_post_format_detect( $data, $postarr ) {
673 global $dc_formattd_post_format;
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
674 if ( defined('XMLRPC_REQUEST') || defined('APP_REQUEST') ) {
675 /* Look for an image at the beginning of a post. Optionally preceded
676 * by <br> or <p> tags. Optionally linked with an <a> tag.
677 */
8badae8 stuff
Dougal Campbell authored Apr 25, 2011
678 if ( preg_match('%^(((<p[^>]*?>)?)((<br ?/?>)*?))*?(<a\s+[^>]+>)?<img\s+[^>]+>%', $post->post_content) ) {
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
679 $dc_formattd_post_format = 'image';
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
680 }
681
682 /* This is insufficient. And transcoding video is a real pain. I think
683 * the best way to handle this is to upload videos to a dedicated
684 * service (YouTube, Vimeo, Flickr, etc), and use plugins to import them
685 * as posts from there. Maybe one day there will be a universal codec
686 * and container format shared by all browsers and mobile devices. Yeah,
687 * right.
688 */
689 /*
690 if ( preg_match('%^(<br ?/?>)*<video\s+[^>]+>%', $post->post_content) ) {
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
691 $dc_formattd_post_format = 'video';
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
692 }
693 */
694
0a4a31e @dougalcampbell Eliminate horizontal scroll bar. Hide certain admin bar areas for mob…
authored Mar 2, 2012
695 /**
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
696 * Look for a :FORMAT: sentinel string in the first 30 chars. If we see
697 * it, use that as the post format. E.g., '<p>:status: Hanging with my
698 * buds</p>' would become a 'format-status' post. The format specifier
699 * is not case-sensitive.
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
700 */
701 $count = preg_match('%:([A-Za-z]+):%', substr($data['post_content'], 0, 30), $matches);
702 if ( $count ) {
703 // Strip our :FORMAT: sentinel string from the content
704 $data['post_content'] = preg_replace('%:'.$matches[1].':\s*%i', '', $data['post_content'], 1);
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
705 $dc_formattd_post_format = $matches[1];
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
706 }
707
0a4a31e @dougalcampbell Eliminate horizontal scroll bar. Hide certain admin bar areas for mob…
authored Mar 2, 2012
708 /**
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
709 * Look for [gallery] in the post. If we see it, set the gallery post
710 * format.
711 */
712 if ( false !== strpos('[gallery]', $data['post_content']) ) {
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
713 $dc_formattd_post_format = 'gallery';
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
714 }
715
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
716 if ( $dc_formattd_post_format ) {
717 add_action( 'wp_insert_post', 'formattd_post_format_set', 10, 2 );
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
718 }
719 }
8badae8 stuff
Dougal Campbell authored Apr 25, 2011
720
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
721 return $data;
722 }
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
723 endif;
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
724
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
725 if (! function_exists('formattd_post_format_set') ) :
726 function formattd_post_format_set( $postid, $post ) {
727 global $dc_formattd_post_format;
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
728 // Validate format
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
729 $dc_formattd_post_format = sanitize_key($dc_formattd_post_format);
8badae8 stuff
Dougal Campbell authored Apr 25, 2011
730
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
731 if ( !array_key_exists( $dc_formattd_post_format, get_post_format_strings() ) ) {
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
732 // not a valid post format. do nothing.
733 return;
734 }
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
735 set_post_format( $postid, $dc_formattd_post_format );
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
736 }
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
737 endif;
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
738
be5b651 Standardized names of all functions to use the 'formattd_' prefix, and
Dougal Campbell authored Apr 29, 2011
739 add_filter('wp_insert_post_data', 'formattd_post_format_detect', 10, 2);
ee6528f Add the remaining formats. More styling. Support for setting post-for…
Dougal Campbell authored Apr 18, 2011
740
Something went wrong with that request. Please try again.