Advertisement
srikat

functions.php

Jan 7th, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.81 KB | None | 0 0
  1. <?php
  2. //* Start the engine
  3. include_once( get_template_directory() . '/lib/init.php' );
  4.  
  5. //* Set Localization (do not remove)
  6.  
  7. //* Child theme (do not remove)
  8. define( 'CHILD_THEME_NAME', __( 'Agency Pro Theme', 'agency' ) );
  9. define( 'CHILD_THEME_URL', 'http://my.studiopress.com/themes/agency/' );
  10. define( 'CHILD_THEME_VERSION', '3.0.0' );
  11.  
  12. //* Add HTML5 markup structure
  13. add_theme_support( 'html5' );
  14.  
  15. //* Add viewport meta tag for mobile browsers
  16. add_theme_support( 'genesis-responsive-viewport' );
  17.  
  18. //* Enqueue EB Garamond and Spinnaker Google fonts
  19. add_action( 'wp_enqueue_scripts', 'agency_google_fonts' );
  20. function agency_google_fonts() {
  21.  
  22.     wp_enqueue_style( 'google-fonts', '//fonts.googleapis.com/css?family=EB+Garamond|Spinnaker', array(), CHILD_THEME_VERSION );
  23.  
  24. }
  25.  
  26. //* Enqueue Backstretch script and prepare images for loading
  27. add_action( 'wp_enqueue_scripts', 'agency_enqueue_backstretch_scripts' );
  28. function agency_enqueue_backstretch_scripts() {
  29.  
  30.     //* Load scripts only if custom background is being used
  31.     if ( ! get_background_image() )
  32.         return;
  33.  
  34.     wp_enqueue_script( 'agency-pro-backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/backstretch.js', array( 'jquery' ), '1.0.0' );
  35.     wp_enqueue_script( 'agency-pro-backstretch-set', get_bloginfo( 'stylesheet_directory' ).'/js/backstretch-set.js' , array( 'jquery', 'agency-pro-backstretch' ), '1.0.0' );
  36.  
  37.     wp_localize_script( 'agency-pro-backstretch-set', 'BackStretchImg', array( 'src' => get_background_image() ) );
  38.  
  39. }
  40.  
  41. //* Add new image sizes
  42. add_image_size( 'home-bottom', 380, 150, TRUE );
  43. add_image_size( 'home-middle', 380, 380, TRUE );
  44.  
  45. //* Add support for custom background
  46. add_theme_support( 'custom-background', array( 'wp-head-callback' => 'agency_background_callback' ) );
  47.  
  48. //* Add custom background callback for background color
  49. function agency_background_callback() {
  50.  
  51.     if ( ! get_background_color() )
  52.         return;
  53.  
  54.     printf( '<style>body { background-color: #%s; }</style>' . "\n", get_background_color() );
  55.  
  56. }
  57.  
  58. //* Add support for custom header
  59. add_theme_support( 'custom-header', array(
  60.     'header_image'    => '',
  61.     'header-selector' => '.site-title a',
  62.     'header-text'     => false,
  63.     'height'          => 60,
  64.     'width'           => 300,
  65. ) );
  66.  
  67. //* Add support for additional color style options
  68. add_theme_support( 'genesis-style-selector', array(
  69.     'agency-pro-blue'   => __( 'Agency Pro Blue', 'agency' ),
  70.     'agency-pro-green'  => __( 'Agency Pro Green', 'agency' ),
  71.     'agency-pro-orange' => __( 'Agency Pro Orange', 'agency' ),
  72.     'agency-pro-red'    => __( 'Agency Pro Red', 'agency' ),
  73. ) );
  74.  
  75. //* Add support for 3-column footer widgets
  76. add_theme_support( 'genesis-footer-widgets', 3 );
  77.  
  78. //* Reposition the header
  79. remove_action( 'genesis_header', 'genesis_header_markup_open', 5 );
  80. remove_action( 'genesis_header', 'genesis_do_header' );
  81. remove_action( 'genesis_header', 'genesis_header_markup_close', 15 );
  82. add_action( 'genesis_before', 'genesis_header_markup_open', 5 );
  83. add_action( 'genesis_before', 'genesis_do_header', 10 );
  84. add_action( 'genesis_before', 'genesis_header_markup_close', 15 );
  85.  
  86. //* Remove the site description
  87. remove_action( 'genesis_site_description', 'genesis_seo_site_description' );
  88.  
  89. //* Register widget areas
  90. genesis_register_sidebar( array(
  91.     'id'          => 'home-top',
  92.     'name'        => __( 'Home Top', 'agency' ),
  93.     'description' => __( 'This is the top section of the homepage.', 'agency' ),
  94. ) );
  95. genesis_register_sidebar( array(
  96.     'id'          => 'home-middle',
  97.     'name'        => __( 'Home Middle', 'agency' ),
  98.     'description' => __( 'This is the middle section of the homepage.', 'agency' ),
  99. ) );
  100. genesis_register_sidebar( array(
  101.     'id'          => 'home-bottom',
  102.     'name'        => __( 'Home Bottom', 'agency' ),
  103.     'description' => __( 'This is the bottom section of the homepage.', 'agency' ),
  104. ) );
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112. //* Add support for structural wraps
  113. add_theme_support( 'genesis-structural-wraps', array(
  114.   'header',
  115.     'site-tagline',
  116.     'nav',
  117.     'subnav',
  118.     'home-featured',
  119.     'site-inner',
  120.     'footer-widgets',
  121.     'footer'
  122. ) );
  123.  
  124. //* Register Home Featured widget area
  125. genesis_register_sidebar( array(
  126.     'id' => 'home-featured',
  127.     'name' => __( 'Home Featured', 'agency' ),
  128.     'description' => __( 'This is the home featured section.', 'agency' ),
  129. ) );
  130.  
  131. /** Add the home featured section */
  132. add_action( 'genesis_after_header', 'sk_home_featured' );
  133. function sk_home_featured() {
  134.  
  135.     if ( is_active_sidebar( 'home-featured' ) && ( is_home() || is_front_page() ) ) {
  136.         printf( '<div %s>', genesis_attr( 'home-featured' ) );
  137.             genesis_structural_wrap( 'home-featured' );
  138.                 genesis_widget_area( 'home-featured', array(
  139.                     'before' => '<div class="widget-area">',
  140.                     'after' => '</div>'
  141.                     ) );
  142.             genesis_structural_wrap( 'home-featured', 'close' );
  143.         echo '</div>';
  144.     }
  145.  
  146. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement