Guest User

Functions Genesis

a guest
Oct 11th, 2013
63
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /** Start the engine */
  3.  
  4. require_once( get_template_directory() . '/lib/init.php' );
  5.  
  6.  
  7.  
  8. load_child_theme_textdomain( 'executive', apply_filters( 'child_theme_textdomain', get_stylesheet_directory() . '/languages', 'executive' ) );
  9.  
  10. // Enable HTML5 markup
  11. add_theme_support( 'html5' );
  12.  
  13. /** Child theme (do not remove) */
  14.  
  15. define( 'CHILD_THEME_NAME', __( 'Executive Theme', 'executive' ) );
  16.  
  17. define( 'CHILD_THEME_URL', 'http://www.studiopress.com/themes/executive' );
  18.  
  19.  
  20.  
  21. /** Add Viewport meta tag for mobile browsers */
  22.  
  23. add_action( 'genesis_meta', 'executive_add_viewport_meta_tag' );
  24.  
  25. function executive_add_viewport_meta_tag() {
  26.  
  27.     echo '<meta name="viewport" content="width=device-width, initial-scale=1.0"/>';
  28.  
  29. }
  30.  
  31.  
  32.  
  33. /** Add support for custom header */
  34.  
  35. add_theme_support( 'genesis-custom-header', array(
  36.  
  37.     'width'     => 1140,
  38.  
  39.     'height'    => 100
  40.  
  41. ) );
  42.  
  43.  
  44.  
  45. /** Add support for custom background */
  46.  
  47. add_theme_support( 'custom-background' );
  48.  
  49.  
  50.  
  51. /** Sets Content Width */
  52.  
  53. $content_width = apply_filters( 'content_width', 680, 680, 1020 );
  54.  
  55.  
  56.  
  57. /** Create additional color style options */
  58.  
  59. add_theme_support( 'genesis-style-selector', array(
  60.  
  61.     'executive-brown'   =>  __( 'Brown', 'executive' ),
  62.  
  63.     'executive-green'   =>  __( 'Green', 'executive' ),
  64.  
  65.     'executive-orange'  =>  __( 'Orange', 'executive' ),
  66.  
  67.     'executive-purple'  =>  __( 'Purple', 'executive' ),
  68.  
  69.     'executive-red'     =>  __( 'Red', 'executive' ),
  70.  
  71.     'executive-teal'    =>  __( 'Teal', 'executive' ),
  72.  
  73. ) );
  74.  
  75.  
  76.  
  77. /** Unregister layout settings */
  78.  
  79. genesis_unregister_layout( 'content-sidebar-sidebar' );
  80.  
  81. genesis_unregister_layout( 'sidebar-content-sidebar' );
  82.  
  83. genesis_unregister_layout( 'sidebar-sidebar-content' );
  84.  
  85.  
  86.  
  87. /** Unregister secondary sidebar */
  88.  
  89. unregister_sidebar( 'sidebar-alt' );
  90.  
  91.  
  92.  
  93. /** Add new image sizes */
  94.  
  95. add_image_size( 'featured', 285, 100, TRUE );
  96.  
  97. add_image_size( 'portfolio', 300, 200, TRUE );
  98.  
  99. add_image_size( 'slider', 1140, 445, TRUE );
  100.  
  101.  
  102.  
  103. /** Remove the site description */
  104.  
  105. remove_action( 'genesis_site_description', 'genesis_seo_site_description' );
  106.  
  107.  
  108.  
  109. /** Relocate the post info */
  110.  
  111. remove_action( 'genesis_entry_header', 'genesis_post_info' );
  112.  
  113. add_action( 'genesis_entry_header', 'genesis_post_info' );
  114.  
  115.  
  116.  
  117. /** Customize the post info function */
  118.  
  119. add_filter( 'genesis_post_info', 'post_info_filter' );
  120.  
  121. function post_info_filter($post_info) {
  122.  
  123.     if (!is_page()) {
  124.  
  125.         $post_info = '
  126.  
  127.         <div class=\'date-info\'>' .
  128.  
  129.             __('by', 'executive' ) . ' [post_author_posts_link] [post_edit]
  130.  
  131.         </div>
  132.  
  133.         <div class="comments">
  134.  
  135.             [post_comments]
  136.  
  137.         </div>';
  138.  
  139.         return $post_info;
  140.  
  141.     }
  142.  
  143. }
  144.  
  145.  
  146.  
  147. /** Change the default comment callback */
  148.  
  149. add_filter( 'genesis_comment_list_args', 'executive_comment_list_args' );
  150.  
  151. function executive_comment_list_args( $args ) {
  152.  
  153.     $args['callback'] = 'executive_comment_callback';
  154.  
  155.    
  156.  
  157.     return $args;
  158.  
  159. }
  160.  
  161.  
  162.  
  163. /** Customize the comment section */
  164.  
  165. function executive_comment_callback( $comment, $args, $depth ) {
  166.  
  167.  
  168.  
  169.     $GLOBALS['comment'] = $comment; ?>
  170.  
  171.  
  172.  
  173.     <li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
  174.  
  175.  
  176.  
  177.         <?php do_action( 'genesis_before_comment' ); ?>
  178.  
  179.        
  180.  
  181.         <div class="comment-header">
  182.  
  183.             <div class="comment-author vcard">
  184.  
  185.                 <?php echo get_avatar( $comment, $size = $args['avatar_size'] ); ?>
  186.  
  187.                 <?php printf( '<cite class="fn">%s</cite> <span class="says">%s:</span>', get_comment_author_link(), apply_filters( 'comment_author_says_text', __( 'says', 'executive' ) ) ); ?>
  188.  
  189.                 <div class="comment-meta commentmetadata">
  190.  
  191.                     <a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>"><?php printf( '%1$s ' . __('at', 'executive' ) . ' %2$s', get_comment_date(), get_comment_time() ); ?></a>
  192.  
  193.                 <?php edit_comment_link( __( 'Edit', 'executive' ), g_ent( '&bull; ' ), '' ); ?>
  194.  
  195.                 </div><!-- end .comment-meta -->
  196.  
  197.             </div><!-- end .comment-author -->         
  198.  
  199.         </div><!-- end .comment-header --> 
  200.  
  201.  
  202.  
  203.         <div class="comment-content">
  204.  
  205.             <?php if ($comment->comment_approved == '0') : ?>
  206.  
  207.                 <p class="alert"><?php echo apply_filters( 'genesis_comment_awaiting_moderation', __( 'Your comment is awaiting moderation.', 'executive' ) ); ?></p>
  208.  
  209.             <?php endif; ?>
  210.  
  211.  
  212.  
  213.             <?php comment_text(); ?>
  214.  
  215.         </div><!-- end .comment-content -->
  216.  
  217.  
  218.  
  219.         <div class="reply">
  220.  
  221.             <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  222.  
  223.         </div>
  224.  
  225.  
  226.  
  227.         <?php do_action( 'genesis_after_comment' );
  228.  
  229.  
  230.  
  231.     /** No ending </li> tag because of comment threading */
  232.  
  233.  
  234.  
  235. }
  236.  
  237.  
  238.  
  239. /** Create portfolio custom post type */
  240.  
  241. add_action( 'init', 'executive_portfolio_post_type' );
  242.  
  243. function executive_portfolio_post_type() {
  244.  
  245.     register_post_type( 'portfolio',
  246.  
  247.         array(
  248.  
  249.             'labels' => array(
  250.  
  251.                 'name' => __( 'Portfolio', 'executive' ),
  252.  
  253.                 'singular_name' => __( 'Portfolio', 'executive' ),
  254.  
  255.             ),
  256.  
  257.             'exclude_from_search' => true,
  258.  
  259.             'has_archive' => true,
  260.  
  261.             'hierarchical' => true,
  262.  
  263.             'menu_icon' => get_stylesheet_directory_uri() . '/images/icons/portfolio.png',
  264.  
  265.             'public' => true,
  266.  
  267.             'rewrite' => array( 'slug' => 'portfolio' ),
  268.  
  269.             'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes', 'genesis-seo' ),
  270.  
  271.         )
  272.  
  273.     );
  274.  
  275. }
  276.  
  277.  
  278.  
  279. /** Change the number of portfolio items to be displayed (props Bill Erickson) */
  280.  
  281. add_action( 'pre_get_posts', 'executive_portfolio_items' );
  282.  
  283. function executive_portfolio_items( $query ) {
  284.  
  285.  
  286.  
  287.     if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'portfolio' ) ) {
  288.  
  289.         $query->set( 'posts_per_page', '12' );
  290.  
  291.     }
  292.  
  293.  
  294.  
  295. }
  296.  
  297.  
  298.  
  299. /** Add support for 3-column footer widgets */
  300.  
  301. add_theme_support( 'genesis-footer-widgets', 3 );
  302.  
  303.  
  304.  
  305. /** Register widget areas **/
  306.  
  307. genesis_register_sidebar( array(
  308.  
  309.     'id'            => 'home-slider',
  310.  
  311.     'name'          => __( 'Home - Slider', 'executive' ),
  312.  
  313.     'description'   => __( 'This is the slider section on the home page.', 'executive' ),
  314.  
  315. ) );
  316.  
  317. genesis_register_sidebar( array(
  318.  
  319.     'id'            => 'home-top',
  320.  
  321.     'name'          => __( 'Home - Top', 'executive' ),
  322.  
  323.     'description'   => __( 'This is the top section of the home page.', 'executive' ),
  324.  
  325. ) );
  326.  
  327. genesis_register_sidebar( array(
  328.  
  329.     'id'            => 'home-cta',
  330.  
  331.     'name'          => __( 'Home - Call To Action', 'executive' ),
  332.  
  333.     'description'   => __( 'This is the call to action section on the home page.', 'executive' ),
  334.  
  335. ) );
  336.  
  337. genesis_register_sidebar( array(
  338.  
  339.     'id'            => 'home-middle',
  340.  
  341.     'name'          => __( 'Home - Middle', 'executive' ),
  342.  
  343.     'description'   => __( 'This is the middle section of the home page.', 'executive' ),
  344.  
  345. ) );
  346.  
  347.  
  348.  
  349. /** Customize the credits */
  350.  
  351. add_filter( 'genesis_footer_creds_text', 'custom_footer_creds_text' );
  352.  
  353. function custom_footer_creds_text() {
  354.  
  355.     echo '<div class="creds"><p>';
  356.  
  357.     echo 'Copyright &copy; 2012 - ';
  358.  
  359.     echo date('Y');
  360.  
  361.     echo ' &middot; <a href="http://lonerwolf.com">LONERWOLF.COM</a>. All Rights Reserved. &middot; Designed by <a href="http://lonerwolf.com/sol/" title="Sol">Sol</a> &amp; <a href="http://lonerwolf.com/luna/" title="Luna">Luna</a> ';
  362.  
  363.     echo '</p></div>';
  364.  
  365. }
  366.  
  367. // Register newsletter widget area
  368.  
  369.  
  370.  
  371. genesis_register_sidebar( array(
  372.  
  373.  
  374.  
  375.     'id'        => 'newsletter',
  376.  
  377.  
  378.  
  379.     'name'      => __( 'Newsletter', 'custom-theme' ),
  380.  
  381.  
  382.  
  383.     'description'   => __( 'This is the newsletter section.', 'custom-theme' ),
  384.  
  385.  
  386.  
  387. ) );
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395. // Add the newsletter widget after the post content
  396.  
  397. add_action( 'genesis_entry_footer', 'custom_add_newsletter_box' );
  398.  
  399. function custom_add_newsletter_box() {
  400.  
  401.     if ( is_singular( 'post' ) )
  402.  
  403.     genesis_widget_area( 'newsletter', array(
  404.  
  405.         'before' => '<div id="newsletter">',
  406.                 'after' => '</div>',
  407.  
  408.     ) );
  409.  
  410. }
  411.  
  412. //* Load Cinzel Google fonts
  413. add_action( 'wp_enqueue_scripts', 'custom_load_google_fonts' );
  414. function custom_load_google_fonts() {
  415.     wp_enqueue_style( 'google-font', 'http://fonts.googleapis.com/css?family=Cinzel:700', array(), PARENT_THEME_VERSION );
  416. }
  417.  
  418. /** Remove the post meta function */
  419.  
  420. remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
RAW Paste Data