PageRenderTime 51ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/functions.php

https://github.com/fprestes/Conde-WordPress-Theme
PHP | 558 lines | 336 code | 71 blank | 151 comment | 28 complexity | f0dd60ef1275c39931c7d6c2f40d9cdc MD5 | raw file
  1. <?php
  2. /* -----------------------------------------------------------------------------------------------
  3. * FOURSQUARE THEME FUNCTIONS
  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. *
  9. *
  10. * @package WordPress
  11. * @subpackage Foursquare Two
  12. * @since Foursquare Two 1.0
  13. *
  14. * Last Updated: February 22, 2012
  15. ------------------------------------------------------------------------------------------------ */
  16. ################################################################################
  17. // SETUP
  18. ################################################################################
  19. // Include Function Files
  20. require_once('assets/functions/admin-profile-options.php');
  21. require_once('assets/functions/admin-theme-options.php');
  22. require_once('assets/functions/custom-post-types.php');
  23. require_once('assets/functions/shortcodes.php');
  24. require_once('assets/functions/breadcrumbs.php');
  25. require_once('assets/functions/class-tgm-plugin-activation.php');
  26. // Set the content width based on the theme's design and stylesheet.
  27. if ( ! isset( $content_width ) )
  28. $content_width = 640;
  29. // Tell WordPress to run foursquare_setup() when the 'after_setup_theme' hook is run.
  30. add_action( 'after_setup_theme', 'foursquare_setup' );
  31. if ( ! function_exists( 'foursquare_setup' ) ):
  32. // Load all CSS files in the currect order!
  33. function bootstrapwp_css_loader() {
  34. wp_enqueue_style('bootstrap.css', get_template_directory_uri().'/assets/styles/bootstrap/bootstrap.css', false ,'1.0', 'all' );
  35. wp_enqueue_style('style.css', get_template_directory_uri().'/style.css', false ,'1.0', 'all' );
  36. wp_enqueue_style('responsive.css', get_template_directory_uri().'/assets/styles/bootstrap/responsive.css', false ,'1.0', 'all' );
  37. }
  38. add_action('wp_enqueue_scripts', 'bootstrapwp_css_loader');
  39. // Sets up theme defaults and registers support for various WordPress features.
  40. function foursquare_setup() {
  41. // This theme styles the visual editor with editor-style.css to match the theme style.
  42. add_editor_style();
  43. // This theme uses post thumbnails
  44. add_theme_support( 'post-thumbnails' );
  45. // Add default posts and comments RSS feed links to head
  46. add_theme_support( 'automatic-feed-links' );
  47. // Make theme available for translation
  48. // Translations can be filed in the /languages/ directory
  49. load_theme_textdomain( 'foursquare', TEMPLATEPATH . '/languages' );
  50. $locale = get_locale();
  51. $locale_file = TEMPLATEPATH . "/languages/$locale.php";
  52. if ( is_readable( $locale_file ) )
  53. require_once( $locale_file );
  54. // This theme uses wp_nav_menu() in one location.
  55. register_nav_menus( array(
  56. 'primary' => __( 'Primary Navigation', 'foursquare' ),
  57. ) );
  58. // Custom header starts here
  59. if ( ! defined( 'HEADER_TEXTCOLOR' ) )
  60. define( 'HEADER_TEXTCOLOR', '' );
  61. // No CSS, just IMG call. The %s is a placeholder for the theme template directory URI.
  62. if ( ! defined( 'HEADER_IMAGE' ) )
  63. define( 'HEADER_IMAGE', '' );
  64. // The height and width of your custom header. You can hook into the theme's own filters to change these values.
  65. // Add a filter to foursquare_header_image_width and foursquare_header_image_height to change these values.
  66. define( 'HEADER_IMAGE_WIDTH', apply_filters( 'foursquare_header_image_width', 570 ) );
  67. define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'foursquare_header_image_height', 85 ) );
  68. // We'll be using post thumbnails for custom header images on posts and pages.
  69. // We want them to be 940 pixels wide by 198 pixels tall.
  70. // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
  71. set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
  72. // Don't support text inside the header image.
  73. if ( ! defined( 'NO_HEADER_TEXT' ) )
  74. define( 'NO_HEADER_TEXT', true );
  75. // Add a way for the custom header to be styled in the admin panel that controls
  76. // custom headers. See foursquare_admin_header_style(), below.
  77. add_custom_image_header( '', 'foursquare_admin_header_style' );
  78. // ... and thus ends the custom header business.
  79. }
  80. endif;
  81. if ( ! function_exists( 'foursquare_admin_header_style' ) ) :
  82. /**
  83. * Styles the header image displayed on the Appearance > Header admin panel.
  84. *
  85. * Referenced via add_custom_image_header() in foursquare_setup().
  86. *
  87. * @since Twenty Ten 1.0
  88. */
  89. function foursquare_admin_header_style() {
  90. ?>
  91. <style type="text/css">
  92. /* Shows the same border as on front end */
  93. #headimg {
  94. border-bottom: 1px solid #000;
  95. border-top: 4px solid #000;
  96. min-height: 85px !important;
  97. }
  98. /* If NO_HEADER_TEXT is false, you would style the text with these selectors:
  99. #headimg #name { }
  100. #headimg #desc { }
  101. */
  102. </style>
  103. <?php
  104. }
  105. endif;
  106. // Include Required Plugins
  107. /**
  108. *
  109. * It is expected that theme authors would copy and paste this code into their
  110. * functions.php file, and amend to suit.
  111. *
  112. * @package TGM-Plugin-Activation
  113. * @subpackage Example
  114. * @version 2.3.3
  115. * @author Thomas Griffin <thomas@thomasgriffinmedia.com>
  116. * @author Gary Jones <gamajo@gamajo.com>
  117. * @copyright Copyright (c) 2012, Thomas Griffin
  118. * @license http://opensource.org/licenses/gpl-2.0.php GPL v2 or later
  119. * @link https://github.com/thomasgriffin/TGM-Plugin-Activation
  120. */
  121. /**
  122. * Include the TGM_Plugin_Activation class.
  123. */
  124. add_action( 'tgmpa_register', 'my_theme_register_required_plugins' );
  125. /**
  126. * Register the required plugins for this theme.
  127. *
  128. * In this example, we register two plugins - one included with the TGMPA library
  129. * and one from the .org repo.
  130. *
  131. * The variable passed to tgmpa_register_plugins() should be an array of plugin
  132. * arrays.
  133. *
  134. * This function is hooked into tgmpa_init, which is fired within the
  135. * TGM_Plugin_Activation class constructor.
  136. */
  137. function my_theme_register_required_plugins() {
  138. /**
  139. * Array of plugin arrays. Required keys are name and slug.
  140. * If the source is NOT from the .org repo, then source is also required.
  141. */
  142. $plugins = array(
  143. // Plugins that are pre-packaged with a theme
  144. array(
  145. 'name' => 'Hero Content Slider', // The plugin name
  146. 'slug' => 'flexslider', // The plugin slug (typically the folder name)
  147. 'source' => get_stylesheet_directory() . '/assets/plugins/flexslider.zip', // The plugin source
  148. 'required' => true, // If false, the plugin is only 'recommended' instead of required
  149. 'version' => '', // E.g. 1.0.0. If set, the active plugin must be this version or higher
  150. 'force_activation' => true, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch
  151. 'force_deactivation' => true, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins
  152. 'external_url' => '', // If set, overrides default API URL and points to an external URL
  153. ),
  154. array(
  155. 'name' => 'The Events Calendar', // The plugin name
  156. 'slug' => 'the-events-calendar', // The plugin slug (typically the folder name)
  157. 'source' => get_stylesheet_directory() . '/assets/plugins/the-events-calendar.zip', // The plugin source
  158. 'required' => false, // If false, the plugin is only 'recommended' instead of required
  159. 'version' => '', // E.g. 1.0.0. If set, the active plugin must be this version or higher
  160. 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch
  161. 'force_deactivation' => true, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins
  162. 'external_url' => '', // If set, overrides default API URL and points to an external URL
  163. ),
  164. array(
  165. 'name' => 'Foursquare Twitter Widget', // The plugin name
  166. 'slug' => 'fs-twitter-widget', // The plugin slug (typically the folder name)
  167. 'source' => get_stylesheet_directory() . '/assets/plugins/fs-twitter-widget.zip', // The plugin source
  168. 'required' => true, // If false, the plugin is only 'recommended' instead of required
  169. 'version' => '', // E.g. 1.0.0. If set, the active plugin must be this version or higher
  170. 'force_activation' => true, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch
  171. 'force_deactivation' => true, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins
  172. 'external_url' => '', // If set, overrides default API URL and points to an external URL
  173. ),
  174. array(
  175. 'name' => 'Contact Form 7',
  176. 'slug' => 'contact-form-7',
  177. 'source' => get_stylesheet_directory() . '/assets/plugins/contact-form-7.zip',
  178. 'required' => true,
  179. 'version' => '',
  180. 'force_activation' => true,
  181. 'force_deactivation' => false,
  182. 'external_url' => '',
  183. ),
  184. array(
  185. 'name' => 'WordPress Gzip Compression',
  186. 'slug' => 'wordpress-gzip-compression',
  187. 'source' => get_stylesheet_directory() . '/assets/plugins/wordpress-gzip-compression',
  188. 'required' => true,
  189. 'version' => '',
  190. 'force_activation' => true,
  191. 'force_deactivation' => false,
  192. 'external_url' => '',
  193. ),
  194. // Plugins from the WordPress Plugin Repository
  195. array(
  196. 'name' => '',
  197. 'slug' => '',
  198. 'required' => false,
  199. ),
  200. );
  201. // Change this to your theme text domain, used for internationalising strings
  202. $theme_text_domain = 'tgmpa';
  203. /**
  204. * Array of configuration settings. Amend each line as needed.
  205. * If you want the default strings to be available under your own theme domain,
  206. * leave the strings uncommented.
  207. * Some of the strings are added into a sprintf, so see the comments at the
  208. * end of each line for what each argument will be.
  209. */
  210. $config = array(
  211. 'domain' => $theme_text_domain, // Text domain - likely want to be the same as your theme.
  212. 'default_path' => '', // Default absolute path to pre-packaged plugins
  213. 'parent_menu_slug' => 'themes.php', // Default parent menu slug
  214. 'parent_url_slug' => 'themes.php', // Default parent URL slug
  215. 'menu' => 'install-required-plugins', // Menu slug
  216. 'has_notices' => true, // Show admin notices or not
  217. 'is_automatic' => false, // Automatically activate plugins after installation or not
  218. 'message' => '', // Message to output right before the plugins table
  219. 'strings' => array(
  220. 'page_title' => __( 'Install Required Plugins', $theme_text_domain ),
  221. 'menu_title' => __( 'Install Plugins', $theme_text_domain ),
  222. 'installing' => __( 'Installing Plugin: %s', $theme_text_domain ), // %1$s = plugin name
  223. 'oops' => __( 'Something went wrong with the plugin API.', $theme_text_domain ),
  224. 'notice_can_install_required' => _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.' ), // %1$s = plugin name(s)
  225. 'notice_can_install_recommended' => _n_noop( 'This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.' ), // %1$s = plugin name(s)
  226. 'notice_cannot_install' => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.' ), // %1$s = plugin name(s)
  227. 'notice_can_activate_required' => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.' ), // %1$s = plugin name(s)
  228. 'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.' ), // %1$s = plugin name(s)
  229. 'notice_cannot_activate' => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.' ), // %1$s = plugin name(s)
  230. 'notice_ask_to_update' => _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.' ), // %1$s = plugin name(s)
  231. 'notice_cannot_update' => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.' ), // %1$s = plugin name(s)
  232. 'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins' ),
  233. 'activate_link' => _n_noop( 'Activate installed plugin', 'Activate installed plugins' ),
  234. 'return' => __( 'Return to Required Plugins Installer', $theme_text_domain ),
  235. 'plugin_activated' => __( 'Plugin activated successfully.', $theme_text_domain ),
  236. 'complete' => __( 'All plugins installed and activated successfully. %s', $theme_text_domain ) // %1$s = dashboard link
  237. )
  238. );
  239. tgmpa( $plugins, $config );
  240. }
  241. ################################################################################
  242. // HEAD FUNCTIONS
  243. ################################################################################
  244. // Makes some changes to the <title> tag, by filtering the output of wp_title().
  245. /*----------------------------------------------------------------------------*/
  246. function foursquare_filter_wp_title( $title, $separator ) {
  247. // Don't affect wp_title() calls in feeds.
  248. if ( is_feed() )
  249. return $title;
  250. // The $paged global variable contains the page number of a listing of posts.
  251. // The $page global variable contains the page number of a single post that is paged.
  252. // We'll display whichever one applies, if we're not looking at the first page.
  253. global $paged, $page;
  254. if ( is_search() ) {
  255. // If we're a search, let's start over:
  256. $title = sprintf( __( 'Search results for %s', 'foursquare' ), '"' . get_search_query() . '"' );
  257. // Add a page number if we're on page 2 or more:
  258. if ( $paged >= 2 )
  259. $title .= " $separator " . sprintf( __( 'Page %s', 'foursquare' ), $paged );
  260. // Add the site name to the end:
  261. $title .= " $separator " . get_bloginfo( 'name', 'display' );
  262. // We're done. Let's send the new title back to wp_title():
  263. return $title;
  264. }
  265. // Otherwise, let's start by adding the site name to the end:
  266. $title .= get_bloginfo( 'name', 'display' );
  267. // If we have a site description and we're on the home/front page, add the description:
  268. $site_description = get_bloginfo( 'description', 'display' );
  269. if ( $site_description && ( is_home() || is_front_page() ) )
  270. $title .= " $separator " . $site_description;
  271. // Add a page number if necessary:
  272. if ( $paged >= 2 || $page >= 2 )
  273. $title .= " $separator " . sprintf( __( 'Page %s', 'foursquare' ), max( $paged, $page ) );
  274. // Return the new title to wp_title():
  275. return $title;
  276. }
  277. add_filter( 'wp_title', 'foursquare_filter_wp_title', 10, 2 );
  278. // Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
  279. /*----------------------------------------------------------------------------*/
  280. function foursquare_page_menu_args( $args ) {
  281. $args['show_home'] = true;
  282. return $args;
  283. }
  284. add_filter( 'wp_page_menu_args', 'foursquare_page_menu_args' );
  285. ################################################################################
  286. // Comments and Pingbacks
  287. ################################################################################
  288. if ( ! function_exists( 'foursquare_comment' ) ) :
  289. function foursquare_comment( $comment, $args, $depth ) {
  290. $GLOBALS['comment'] = $comment;
  291. switch ( $comment->comment_type ) :
  292. case '' :
  293. ?>
  294. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
  295. <div id="comment-<?php comment_ID(); ?>">
  296. <h3 class="comment-author vcard">
  297. <?php echo get_avatar( $comment, 60 ); ?>
  298. <?php printf( __( '%s', 'foursquare' ), sprintf( '%s', get_comment_author_link() ) ); ?>
  299. </h3><!-- .comment-author .vcard -->
  300. <?php if ( $comment->comment_approved == '0' ) : ?>
  301. <strong><?php _e( 'Your comment is awaiting moderation.', 'foursquare' ); ?></strong>
  302. <br />
  303. <?php endif; ?>
  304. <div class="comment-meta commentmetadata"><i>
  305. <?php
  306. /* translators: 1: date, 2: time */
  307. printf( __( '%1$s at %2$s', 'foursquare' ), get_comment_date(), get_comment_time() ); ?><?php edit_comment_link( __( '(Edit)', 'foursquare' ), ' ' );
  308. ?></i><br /><br />
  309. </div><!-- .comment-meta .commentmetadata -->
  310. <div class="comment-body"><?php comment_text(); ?></div>
  311. <div class="reply button btn-reply">
  312. <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  313. </div><!-- .reply -->
  314. </div><!-- #comment-## -->
  315. <?php
  316. break;
  317. case 'pingback' :
  318. case 'trackback' :
  319. ?>
  320. <li class="post pingback">
  321. <p><?php _e( 'Pingback:', 'foursquare' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __('(Edit)', 'foursquare'), ' ' ); ?></p>
  322. <?php
  323. break;
  324. endswitch;
  325. }
  326. endif;
  327. ################################################################################
  328. // POST FUNCTIONS
  329. ################################################################################
  330. // Prints HTML with meta information for the current post (category, tags and permalink).
  331. if ( ! function_exists( 'foursquare_posted_in' ) ) :
  332. function foursquare_posted_in() {
  333. // Retrieves tag list of current post, separated by commas.
  334. $tag_list = get_the_tag_list( '', ', ' );
  335. if ( $tag_list ) {
  336. $posted_in = __( 'Tags: %2$s.');
  337. } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
  338. $posted_in = __( 'This entry was posted in %1$s.', 'foursquare' );
  339. } else {
  340. $posted_in = __( '| <a href="%3$s" title="Permalink to %4$s" rel="bookmark">Permalink</a>.', 'foursquare' );
  341. }
  342. // Prints the string, replacing the placeholders.
  343. printf(
  344. $posted_in,
  345. get_the_category_list( ', ' ),
  346. $tag_list,
  347. get_permalink(),
  348. the_title_attribute( 'echo=0' )
  349. );
  350. }
  351. endif;
  352. // Thumbnail Image Sizes
  353. /*----------------------------------------------------------------------------*/
  354. // Thumbnail image size for Sermon custom post type
  355. if ( function_exists( 'add_image_size' ) ) {
  356. add_image_size( 'sermons', '270', '105', 'true' ); //(cropped)
  357. }
  358. // Post Excerpts
  359. /*----------------------------------------------------------------------------*/
  360. // Length: 25 words
  361. function foursquare_excerpt_length( $length ) {
  362. return 25;
  363. }
  364. add_filter( 'excerpt_length', 'foursquare_excerpt_length' );
  365. // Returns a "Continue Reading" link for excerpts
  366. function foursquare_continue_reading_link() {
  367. return ' <p><a class="btn btn-primary" href="'. get_permalink() . '">' . __( 'Read more', 'foursquare' ) . '</a></p>';
  368. }
  369. // Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and foursquare_continue_reading_link().
  370. function foursquare_auto_excerpt_more( $more ) {
  371. return ' &hellip;' . foursquare_continue_reading_link();
  372. }
  373. add_filter( 'excerpt_more', 'foursquare_auto_excerpt_more' );
  374. // Adds a pretty "Continue Reading" link to custom post excerpts.
  375. function foursquare_custom_excerpt_more( $output ) {
  376. if ( has_excerpt() && ! is_attachment() ) {
  377. $output .= foursquare_continue_reading_link();
  378. }
  379. return $output;
  380. }
  381. add_filter( 'get_the_excerpt', 'foursquare_custom_excerpt_more' );
  382. // Length: 15 words. Used on Home blog feed and Sermon Archive.
  383. function wpe_excerptlength_teaser($length) {
  384. return 15;
  385. }
  386. add_filter( 'excerpt_length', 'foursquare_excerpt_length' );
  387. // Length: 40 words
  388. function wpe_excerptlength_searchteaser($length) {
  389. return 40;
  390. }
  391. // Length: 85 words
  392. function wpe_excerptlength_events($length) {
  393. return 85;
  394. }
  395. // Register the "More" function for custom length excerpts
  396. function wpe_excerptmore($more) {
  397. return '';
  398. }
  399. function wpe_excerpt($length_callback='', $more_callback='') {
  400. global $post;
  401. if(function_exists($length_callback)){
  402. add_filter('excerpt_length', $length_callback);
  403. }
  404. if(function_exists($more_callback)){
  405. add_filter('excerpt_more', $more_callback);
  406. }
  407. $output = get_the_excerpt();
  408. $output = apply_filters('wptexturize', $output);
  409. $output = apply_filters('convert_chars', $output);
  410. $output = '<p>'.$output.'</p>';
  411. echo $output;
  412. }
  413. ################################################################################
  414. // REGISTER SIDEBARS
  415. ################################################################################
  416. function foursquare_widgets_init() {
  417. // Area 1, located at the bottom of the site. Allows two widgets (third space is a feed for Latest Sermons.
  418. register_sidebar( array(
  419. 'name' => __( 'Footer Widgets', 'foursquare' ),
  420. 'id' => 'primary-widget-area',
  421. 'description' => __( 'The two widgets to the right of the Latest Sermon at the bottom of the site.', 'foursquare' ),
  422. 'before_widget' => '<div class="span4"><li id="%1$s" class="widget-container %2$s">',
  423. 'after_widget' => '</li></div>',
  424. 'before_title' => '<h2 class="widget-title">',
  425. 'after_title' => '</h2>',
  426. ) );
  427. // Area 2, located on all subpages. Empty by default.
  428. register_sidebar( array(
  429. 'name' => __( 'Subpage Widgets', 'foursquare' ),
  430. 'id' => 'subpage-widget-area',
  431. 'description' => __( 'The widget area for the blog index', 'foursquare' ),
  432. 'before_widget' => '<div class="span4"><li id="%1$s" class="widget-container %2$s">',
  433. 'after_widget' => '</li></div>',
  434. 'before_title' => '<h2 class="widget-title">',
  435. 'after_title' => '</h2>',
  436. ) );
  437. // Area 3, located below content of a Full-Width page. Empty by default.
  438. register_sidebar( array(
  439. 'name' => __( 'Full-Width Page Widgets', 'foursquare' ),
  440. 'id' => 'fullwidth-widget-area',
  441. 'description' => __( 'Text widgets below the content of a page using the full-width template', 'foursquare' ),
  442. 'before_widget' => '<div class="span4"><li id="%1$s" class="widget-container %2$s">',
  443. 'after_widget' => '</li></div>',
  444. 'before_title' => '<h2 class="widget-title">',
  445. 'after_title' => '</h2>',
  446. ) );
  447. // Area 4, located below the Primary Widget Area in the sidebar. Empty by default.
  448. register_sidebar( array(
  449. 'name' => __( 'Blog Widgets', 'foursquare' ),
  450. 'id' => 'blog-widget-area',
  451. 'description' => __( 'The widget area for the blog index', 'foursquare' ),
  452. 'before_widget' => '<div class="span4"><li id="%1$s" class="widget-container %2$s">',
  453. 'after_widget' => '</li></div>',
  454. 'before_title' => '<h2 class="widget-title">',
  455. 'after_title' => '</h2>',
  456. ) );
  457. }
  458. // Register sidebars by running foursquare_widgets_init() on the widgets_init hook. */
  459. add_action( 'widgets_init', 'foursquare_widgets_init' );
  460. ################################################################################
  461. // WIDGETS
  462. ################################################################################
  463. // Removes the default styles that are packaged with the Recent Comments widget.
  464. function foursquare_remove_recent_comments_style() {
  465. global $wp_widget_factory;
  466. remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );
  467. }
  468. add_action( 'widgets_init', 'foursquare_remove_recent_comments_style' );
  469. // Prints HTML with meta information for the current post—date/time and author.
  470. if ( ! function_exists( 'foursquare_posted_on' ) ) :
  471. function foursquare_posted_on() {
  472. printf( __( '<span class="%1$s">Posted on</span> %2$s <span class="meta-sep">by</span> %3$s', 'foursquare' ),
  473. 'meta-prep meta-prep-author',
  474. sprintf( '<span class="entry-date">%3$s</span>',
  475. get_permalink(),
  476. esc_attr( get_the_time() ),
  477. get_the_date()
  478. ),
  479. sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
  480. get_author_posts_url( get_the_author_meta( 'ID' ) ),
  481. sprintf( esc_attr__( 'View all posts by %s', 'foursquare' ), get_the_author() ),
  482. get_the_author()
  483. )
  484. );
  485. }
  486. endif;
  487. ?>