Advertisement
Guest User

functions.php

a guest
Nov 30th, 2013
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.04 KB | None | 0 0
  1. <?php
  2. /** Load the Core Files */
  3. require_once( trailingslashit( get_template_directory() ) . 'lib/init.php' );
  4. new Contango();
  5.  
  6. /** Do theme setup on the 'after_setup_theme' hook. */
  7. add_action( 'after_setup_theme', 'contango_theme_setup' );
  8.  
  9. /** Theme setup function. */
  10. function contango_theme_setup() {
  11.    
  12.     /** Add theme support for Feed Links. */
  13.     add_theme_support( 'automatic-feed-links' );
  14.  
  15.     /** Post Formats */
  16.     add_theme_support( 'post-formats', array( 'aside', 'audio', 'chat', 'gallery', 'image', 'link', 'quote', 'video' ) );
  17.    
  18.     /** Add theme support for Custom Background. */
  19.     add_theme_support( 'custom-background', array( 'default-color' => 'e9e9e9', 'default-image' => '%s/images/bg-pattern.png', 'wp-head-callback' => 'contango_custom_background_callback' ) );
  20.    
  21.     /** Set content width. */
  22.     contango_set_content_width( 580 );
  23.    
  24.     /** Add custom image sizes. */
  25.     add_action( 'init', 'contango_add_image_sizes' );  
  26.    
  27. }
  28.  
  29. /** Adds custom image sizes */
  30. function contango_add_image_sizes() {
  31.     add_image_size( 'featured', 200, 180, true );
  32. }
  33.  
  34. /**
  35.  * This is a fix for when a user sets a custom background color with no custom background image.  What
  36.  * happens is the theme's background image hides the user-selected background color.  If a user selects a
  37.  * background image, we'll just use the WordPress custom background callback.
  38.  *
  39.  * @link http://core.trac.wordpress.org/ticket/16919
  40.  */
  41. function contango_custom_background_callback() {
  42.  
  43.     /* Get the background image. */
  44.     $image = get_background_image();
  45.  
  46.     /* If there's an image, just call the normal WordPress callback. We won't do anything here. */
  47.     if ( !empty( $image ) ) {
  48.         _custom_background_cb();
  49.         return;
  50.     }
  51.  
  52.     /* Get the background color. */
  53.     $color = get_background_color();
  54.  
  55.     /* If no background color, return. */
  56.     if ( empty( $color ) ) {
  57.         return;
  58.     }
  59.  
  60.     /* Use 'background' instead of 'background-color'. */
  61.     $style = "background: #{$color};";
  62.  
  63. ?>
  64. <style type="text/css">body.custom-background { <?php echo trim( $style ); ?> }</style>
  65. <?php
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement