Advertisement
Guest User

Genesis, CPT, ACF, TAG

a guest
Aug 12th, 2013
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 13.25 KB | None | 0 0
  1. <?php
  2. /** Start the engine */
  3. require_once( get_template_directory() . '/lib/init.php' );
  4.  
  5. /** Set Localization (do not remove) */
  6. load_child_theme_textdomain( 'minimum', apply_filters( 'child_theme_textdomain', get_stylesheet_directory() . '/languages', 'minimum' ) );
  7.  
  8. /** Child theme (do not remove) */
  9. define( 'CHILD_THEME_NAME', __( 'Minimum Theme', 'minimum' ) );
  10. define( 'CHILD_THEME_URL', 'http://my.studiopress.com/themes/minimum' );
  11.  
  12. /** Load Google fonts */
  13. add_action( 'wp_enqueue_scripts', 'minimum_load_google_fonts' );
  14. function minimum_load_google_fonts() {
  15.     wp_enqueue_style(
  16.         'google-fonts',
  17.         'http://fonts.googleapis.com/css?family=Open+Sans:400,700',
  18.         array(),
  19.         PARENT_THEME_VERSION
  20.     );
  21. }
  22.  
  23. /** Sets Content Width */
  24. $content_width = apply_filters( 'content_width', 740, 740, 1140 );
  25.  
  26. /** Add Viewport meta tag for mobile browsers */
  27. add_action( 'genesis_meta', 'minimum_add_viewport_meta_tag' );
  28. function minimum_add_viewport_meta_tag() {
  29.     echo '<meta name="viewport" content="width=device-width, initial-scale=1.0"/>';
  30. }
  31.  
  32. /** Add new image sizes */
  33. add_image_size( 'header', 1600, 9999, TRUE );
  34. add_image_size( 'portfolio', 330, 230, TRUE );
  35.  
  36.  
  37. /** Add support for custom background */
  38. add_theme_support( 'custom-background' );
  39.  
  40. /** Add support for custom header */
  41. add_theme_support( 'genesis-custom-header', array(
  42.     'width' => 1140,
  43.     'height' => 160
  44. ) );
  45.  
  46. /** Remove Site Tag Line **/
  47. remove_action( 'genesis_site_description', 'genesis_seo_site_description' );
  48.  
  49. /**
  50.  *
  51.  * Display an address using
  52.  * Genesis column classes and ACF.
  53.  *
  54.  * @author Angie Meeker
  55.  * @uses   Advanced Custom Fields
  56.  */
  57. add_action( 'genesis_post_content', 'theme_prefix_address', 11 );
  58. function theme_prefix_address() {
  59.     // Return early if not a single page
  60.     if ( !is_single() )
  61.         return;
  62.  
  63.     // Store the location data
  64.     $location_data = array(
  65.         'address_1' => get_field( 'Address_1' ),
  66.         'address_2' => get_field( 'street_address_2' ),
  67.         'po_box'    => get_field( 'po_box' ),
  68.         'city'      => get_field( 'city' ),
  69.         'state'     => get_field( 'state' ),
  70.         'zip'       => get_field( 'zip' ),
  71.     );
  72.  
  73.     // Only output if we have location data
  74.     if( $location_data ) {
  75.     echo '<div class="details">Details</div>';
  76.         echo '<div class="location-wrap one-half first">';
  77.             if ( $location_data['address_1'] ) {
  78.                 echo '<div class="location">' . esc_attr( $location_data['address_1'] ) . '</div>';
  79.             }
  80.             if ( $location_data['address_2'] ) {
  81.                 echo '<div class="location">' . esc_attr( $location_data['address_2'] ) . '</div>';
  82.             }
  83.             if ( $location_data['po_box'] ) {
  84.                 echo '<div class="location">' . esc_attr( $location_data['po_box'] ) . '</div>';
  85.             }
  86.             if ( $location_data['city'] ) {
  87.                 echo '<span>' . esc_attr( $location_data['city'] ) . '</span>';
  88.             }
  89.             if ( $location_data['state'] ) {
  90.                 echo '<span>, ' . esc_attr( $location_data['state'] ) . '</span>';
  91.             }
  92.             if ( $location_data['zip'] ) {
  93.                 echo '<span> ' . esc_attr( $location_data['zip'] ) . '</span>';
  94.             }
  95.         echo '</div>';
  96.     }
  97.  
  98.     // Store the touchpoint data
  99.     $touchpoint_data = array(
  100.         'phone'   => get_field( 'phone' ),
  101.         'website' => get_field( 'website' ),
  102.         'email' => get_field( 'email' ),
  103.     );
  104.  
  105.     // Only output if we have touchpoint data
  106.     if ( $touchpoint_data ) {
  107.         echo '<div class="touchpoints-wrap one-half">';
  108.             if ( $touchpoint_data['phone'] ) {
  109.                 echo '<div class="touchpoint">' . esc_attr( $touchpoint_data['phone'] ) . '</div>';
  110.             }
  111.             if ( $touchpoint_data['website'] ) {
  112.                 echo '<div class="touchpoint"><a href="' . esc_url( $touchpoint_data['website'] ) . '">Visit Our Website</a></div>';
  113.             }
  114.             if ( $touchpoint_data['email'] ) {
  115.                 echo '<div class=touchpoint"><a href="mailto:' . esc_attr( $touchpoint_data['email'] ) . '">Email</a></div>';
  116.             }
  117.         echo '</div>';
  118.     }
  119. }
  120.  
  121.  
  122. /**
  123.  *
  124.  * Display an tour using
  125.  * Genesis column classes and ACF.
  126.  *
  127.  * @author Angie Meeker
  128.  * @uses   Advanced Custom Fields
  129.  */
  130. add_action( 'genesis_post_content', 'theme_prefix_tour', 12 );
  131. function theme_prefix_tour() {
  132.     // Return early if not a single page with tours tag
  133.     if ( is_singular( 'attractions' ) && has_term ( 'tours', 'attractiontype' ) )
  134.         return;
  135.  
  136.     // Store the tour data
  137.     $tour_data = array(
  138.         'contact' => get_field( 'contact' ),
  139.         'admission' => get_field( 'admission' ),
  140.         'hours'    => get_field( 'hours' ),
  141.         'coaches_accepted'      => get_field( 'coaches_accepted' ),
  142.         'reservations_required'     => get_field( 'reservations_required' ),
  143.         'length_of_tour'       => get_field( 'length_of_tour' ),
  144.         'location_of_parking'       => get_field( 'location_of_parking' ),
  145.         'comp_policy'       => get_field( 'comp_policy' ),
  146.         'restrooms_available'       => get_field( 'restrooms_available' ),
  147.         'dietary_menu_available'       => get_field( 'dietary_menu_available' ),
  148.     );
  149.  
  150.     // Only output if we have tour data
  151.     if( $tour_data ) {
  152.     echo '<div class="details">Tour Information</div>';
  153.         echo '<div class="location-wrap one-half first">';
  154.             if ( $tour_data['contact'] ) {
  155.                 echo '<div class="location">' . esc_attr( $tour_data['contact'] ) . '</div>';
  156.             }
  157.             if ( $tour_data['admission'] ) {
  158.                 echo '<div class="location">' . esc_attr( $tour_data['admission'] ) . '</div>';
  159.             }
  160.             if ( $tour_data['hours'] ) {
  161.                 echo '<div class="location">' . esc_attr( $tour_data['hours'] ) . '</div>';
  162.             }
  163.             if ( $tour_data['coaches_accepted'] ) {
  164.                 echo '<div class="location">' . esc_attr( $tour_data['coaches_accepted'] ) . '</div>';
  165.             }
  166.             if ( $tour_data['reservations_required'] ) {
  167.                 echo '<div class="location">' . esc_attr( $tour_data['reservations_required'] ) . '</div>';
  168.             }
  169.             if ( $tour_data['length_of_tour'] ) {
  170.                 echo '<div class="location">' . esc_attr( $tour_data['length_of_tour'] ) . '</div>';
  171.             }
  172.             if ( $tour_data['location_of_parking'] ) {
  173.                 echo '<div class="location">' . esc_attr( $tour_data['location_of_parking'] ) . '</div>';
  174.             }
  175.             if ( $tour_data['comp_policy'] ) {
  176.                 echo '<div class="location">' . esc_attr( $tour_data['comp_policy'] ) . '</div>';
  177.             }
  178.             if ( $tour_data['restrooms_available'] ) {
  179.                 echo '<div class="location">' . esc_attr( $tour_data['restrooms_available'] ) . '</div>';
  180.             }
  181.             if ( $tour_data['dietary_menu_available'] ) {
  182.                 echo '<div class="location">' . esc_attr( $tour_data['dietary_menu_available'] ) . '</div>';
  183.             }
  184.         echo '</div>';
  185.     }
  186.  
  187. }
  188.  
  189.  
  190. /** Unregister layout settings */
  191. genesis_unregister_layout( 'content-sidebar-sidebar' );
  192. genesis_unregister_layout( 'sidebar-content-sidebar' );
  193. genesis_unregister_layout( 'sidebar-sidebar-content' );
  194.  
  195. /** Unregister secondary sidebar */
  196. unregister_sidebar( 'sidebar-alt' );
  197.  
  198. /** Add support for structural wraps */
  199. add_theme_support( 'genesis-structural-wraps', array(
  200.     'header',
  201.     'nav',
  202.     'subnav',
  203.     'inner',
  204.     'footer-widgets',
  205.     'footer-trio',
  206.     'footer'
  207. ) );
  208.  
  209. /** Add the featured image section */
  210. add_action( 'genesis_after_header', 'minimum_featured_image' );
  211. function minimum_featured_image() {
  212.     if ( is_home() ) {
  213.         echo '<div id="home-featured"><div class="wrap">';
  214. genesis_widget_area( 'home-slider', array( 'before' => '<div class="home-slider widget-area">', ) );
  215. echo '</div></div>';
  216.     }
  217. }
  218.  
  219. /** Add the page title section */
  220. //add_action( 'genesis_after_header', 'minimum_page_title' );
  221. function minimum_page_title() {
  222.     require_once( get_stylesheet_directory() . '/page-title.php' );
  223. }
  224.  
  225. /** Customize the post info function */
  226. add_filter( 'genesis_post_info', 'post_info_filter' );
  227. function post_info_filter( $post_info ) {
  228. if ( !is_page() ) {
  229.     $post_info = __( 'Posted on', 'minimum' ) . ' [post_date] // [post_comments] [post_edit]';
  230.     return $post_info;
  231. }}
  232.  
  233.  
  234.  
  235. /** Customize the post meta function */
  236. add_filter( 'genesis_post_meta', 'post_meta_filter' );
  237. function post_meta_filter( $post_meta ) {
  238. if ( !is_page() ) {
  239.     $post_meta = '[post_categories before="' . __( 'Filed Under: ', 'minimum' ) . '"] // [post_tags before="' . __( 'Tagged: ', 'minimum' ) . '"]';
  240.     return $post_meta;
  241. }}
  242.  
  243. /** Modify the size of the Gravatar in the author box */
  244. add_filter( 'genesis_author_box_gravatar_size', 'minimum_author_box_gravatar_size' );
  245. function minimum_author_box_gravatar_size( $size ) {
  246.     return '96';
  247. }
  248.  
  249. /** Add support for 4-column footer widgets */
  250. add_theme_support( 'genesis-footer-widgets', 4 );
  251.  
  252. /** Add footer banner if widget area is used */
  253. add_action( 'genesis_footer', 'minimum_footer_banner', 5 );
  254. function minimum_footer_banner() {
  255.  
  256.     if ( is_active_sidebar( 'home-footer-banner' ) ) {
  257.  
  258.         remove_action( 'genesis_footer', 'genesis_do_footer' );
  259.         echo '<div class="home-footer-banner">';   
  260.         dynamic_sidebar( 'home-footer-banner' );
  261.         echo '</div><!-- end .home-footer-banner -->';
  262.  
  263.     }
  264. }
  265.  
  266. /** Add three footer widgets if widget area is used */
  267. add_action( 'genesis_footer', 'minimum_footer_trio', 6 );
  268. function minimum_footer_trio() {
  269.     if ( is_active_sidebar( 'footer-trio1' ) ) {
  270.  
  271.         remove_action( 'genesis_footer', 'minimum_footer_trio' );
  272.         echo '<div class="footer-trio1">'; 
  273.         dynamic_sidebar( 'footer-trio1' );
  274.         echo '</div><!-- end .minimum_footer_trio -->';
  275.  
  276.     }
  277.     if ( is_active_sidebar( 'footer-trio2' ) ) {
  278.  
  279.         remove_action( 'genesis_footer', 'minimum_footer_trio' );
  280.         echo '<div class="footer-trio2">'; 
  281.         dynamic_sidebar( 'footer-trio2' );
  282.         echo '</div><!-- end .minimum_footer_trio -->';
  283.  
  284.     }
  285.     if ( is_active_sidebar( 'footer-trio3' ) ) {
  286.  
  287.         remove_action( 'genesis_footer', 'minimum_footer_trio' );
  288.         echo '<div class="footer-trio3">'; 
  289.         dynamic_sidebar( 'footer-trio3' );
  290.         echo '</div><!-- end .minimum_footer_trio -->';
  291.     }
  292. }
  293.  
  294.  
  295. /** Add custom footer if widget area is used */
  296. add_action( 'genesis_footer', 'minimum_custom_footer', 7 );
  297. function minimum_custom_footer() {
  298.  
  299.     if ( is_active_sidebar( 'custom-footer' ) ) {
  300.  
  301.         remove_action( 'genesis_footer', 'genesis_do_footer' );
  302.         echo '<div class="custom-footer">';
  303.         dynamic_sidebar( 'custom-footer' );
  304.         echo '</div><!-- end .custom-footer -->';
  305.  
  306.     }
  307. }
  308.  
  309.  
  310.  
  311. /** Create portfolio custom post type */
  312. add_action( 'init', 'minimum_portfolio_post_type' );
  313. function minimum_portfolio_post_type() {
  314.     register_post_type( 'portfolio',
  315.         array(
  316.             'labels' => array(
  317.                 'name' => __( 'Portfolio', 'minimum' ),
  318.                 'singular_name' => __( 'Portfolio', 'minimum' ),
  319.             ),
  320.             'exclude_from_search' => true,
  321.             'has_archive' => true,
  322.             'hierarchical' => true,
  323.             'menu_icon' => get_stylesheet_directory_uri() . '/images/icons/portfolio.png',
  324.             'public' => true,
  325.             'rewrite' => array( 'slug' => 'portfolio' ),
  326.             'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes', 'genesis-seo' ),
  327.         )
  328.     );
  329. }
  330.  
  331. /** Change the number of portfolio items to be displayed (props Bill Erickson) */
  332. add_action( 'pre_get_posts', 'minimum_portfolio_items' );
  333. function minimum_portfolio_items( $query ) {
  334.  
  335.     if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'portfolio' ) ) {
  336.         $query->set( 'posts_per_page', '12' );
  337.     }
  338.  
  339. }
  340.  
  341. /** Add the after post section */
  342. add_action( 'genesis_after_post_content', 'minimum_after_post' );
  343. function minimum_after_post() {
  344.    if ( ! is_singular( 'post' ) )
  345.        return;
  346.    genesis_widget_area( 'after-post', array(
  347.        'before' => '<div class="after-post widget-area">',
  348.    ) );
  349. }
  350.  
  351.  
  352.  
  353. /** Register widget area */
  354. genesis_register_sidebar( array(
  355.     'id'    => 'home-slider',
  356.     'name'  => __( 'Home Slider', 'minimum' ),
  357.     'description'   => __( 'This is the home slider', 'minimum' ),
  358. ) );
  359.  
  360. genesis_register_sidebar( array(
  361.     'id'                => 'home-featured-1',
  362.     'name'          => __( 'Home Featured #1', 'minimum' ),
  363.     'description'   => __( 'This is the home featured #1 section.', 'minimum' ),
  364. ) );
  365. genesis_register_sidebar( array(
  366.     'id'                => 'home-featured-2',
  367.     'name'          => __( 'Home Featured #2', 'minimum' ),
  368.     'description'   => __( 'This is the home featured #2 section.', 'minimum' ),
  369. ) );
  370. genesis_register_sidebar( array(
  371.     'id'                => 'home-featured-3',
  372.     'name'          => __( 'Home Featured #3', 'minimum' ),
  373.     'description'   => __( 'This is the home featured #3 section.', 'minimum' ),
  374. ) );
  375. genesis_register_sidebar( array(
  376.     'id'                => 'home-featured-4',
  377.     'name'          => __( 'Home Featured #4', 'minimum' ),
  378.     'description'   => __( 'This is the home featured #4 section.', 'minimum' ),
  379. ) );
  380. genesis_register_sidebar( array(
  381.     'id'                => 'home-footer-banner',
  382.     'name'          => __( 'Home Footer Banner', 'minimum' ),
  383.     'description'   => __( 'This is the home footer banner.', 'minimum' ),
  384. ) );
  385. genesis_register_sidebar( array(
  386.     'id'                => 'footer-trio1',
  387.     'name'          => __( 'Footer Trio 1', 'minimum' ),
  388.     'description'   => __( 'This is the first footer trio widget.', 'minimum' ),
  389. ) );
  390. genesis_register_sidebar( array(
  391.     'id'                => 'footer-trio2',
  392.     'name'          => __( 'Footer Trio 2', 'minimum' ),
  393.     'description'   => __( 'This is the second footer trio widget.', 'minimum' ),
  394. ) );
  395. genesis_register_sidebar( array(
  396.     'id'                => 'footer-trio3',
  397.     'name'          => __( 'Footer Trio 3', 'minimum' ),
  398.     'description'   => __( 'This is the third footer trio widget.', 'minimum' ),
  399. ) );
  400. genesis_register_sidebar( array(
  401.     'id'                => 'custom-footer',
  402.     'name'          => __( 'Custom Footer', 'minimum' ),
  403.     'description'   => __( 'This is the custom footer section.', 'minimum' ),
  404. ) );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement