Advertisement
Guest User

Untitled

a guest
Oct 12th, 2015
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.44 KB | None | 0 0
  1. <?php
  2. //* Start the engine
  3. include_once( get_template_directory() . '/lib/init.php' );
  4.  
  5. //* Setup Theme
  6. include_once( get_stylesheet_directory() . '/lib/theme-defaults.php' );
  7.  
  8. //* Set Localization (do not remove)
  9. load_child_theme_textdomain( 'altitude', apply_filters( 'child_theme_textdomain', get_stylesheet_directory() . '/languages', 'altitude' ) );
  10.  
  11. //* Add Image upload and Color select to WordPress Theme Customizer
  12. require_once( get_stylesheet_directory() . '/lib/customize.php' );
  13.  
  14. //* Include Customizer CSS
  15. include_once( get_stylesheet_directory() . '/lib/output.php' );
  16.  
  17. //* Child theme (do not remove)
  18. define( 'CHILD_THEME_NAME', 'Altitude Pro Theme' );
  19. define( 'CHILD_THEME_URL', 'http://my.studiopress.com/themes/altitude/' );
  20. define( 'CHILD_THEME_VERSION', '1.0.0' );
  21.  
  22. //* Enqueue scripts and styles
  23. add_action( 'wp_enqueue_scripts', 'altitude_enqueue_scripts_styles' );
  24. function altitude_enqueue_scripts_styles() {
  25.  
  26.     wp_enqueue_script( 'altitude-global', get_bloginfo( 'stylesheet_directory' ) . '/js/global.js', array( 'jquery' ), '1.0.0' );
  27.  
  28.     wp_enqueue_style( 'dashicons' );
  29.     wp_enqueue_style( 'altitude-google-fonts', '//fonts.googleapis.com/css?family=Ek+Mukta:200,800', array(), CHILD_THEME_VERSION );
  30.  
  31. }
  32.  
  33. //* Add HTML5 markup structure
  34. add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) );
  35.  
  36. //* Add viewport meta tag for mobile browsers
  37. add_theme_support( 'genesis-responsive-viewport' );
  38.  
  39. //* Add new image sizes
  40. add_image_size( 'featured-page', 1140, 400, TRUE );
  41.  
  42. //* Add support for 1-column footer widget area
  43. add_theme_support( 'genesis-footer-widgets', 1 );
  44.  
  45. //* Add support for footer menu
  46. add_theme_support ( 'genesis-menus' , array ( 'primary' => 'Primary Navigation Menu', 'secondary' => 'Secondary Navigation Menu', 'footer' => 'Footer Navigation Menu' ) );
  47.  
  48. //* Unregister the header right widget area
  49. unregister_sidebar( 'header-right' );
  50.  
  51. //* Reposition the primary navigation menu
  52. remove_action( 'genesis_after_header', 'genesis_do_nav' );
  53. add_action( 'genesis_header', 'genesis_do_nav', 12 );
  54.  
  55. //* Remove output of primary navigation right extras
  56. remove_filter( 'genesis_nav_items', 'genesis_nav_right', 10, 2 );
  57. remove_filter( 'wp_nav_menu_items', 'genesis_nav_right', 10, 2 );
  58.  
  59. //* Reposition the secondary navigation menu
  60. remove_action( 'genesis_after_header', 'genesis_do_subnav' );
  61. add_action( 'genesis_header', 'genesis_do_subnav', 5 );
  62.  
  63. //* Add secondary-nav class if secondary navigation is used
  64. add_filter( 'body_class', 'altitude_secondary_nav_class' );
  65. function altitude_secondary_nav_class( $classes ) {
  66.  
  67.     $menu_locations = get_theme_mod( 'nav_menu_locations' );
  68.  
  69.     if ( ! empty( $menu_locations['secondary'] ) ) {
  70.         $classes[] = 'secondary-nav';
  71.     }
  72.     return $classes;
  73.  
  74. }
  75.  
  76. //* Hook menu in footer
  77. add_action( 'genesis_footer', 'rainmaker_footer_menu', 7 );
  78. function rainmaker_footer_menu() {
  79.     printf( '<nav %s>', genesis_attr( 'nav-footer' ) );
  80.     wp_nav_menu( array(
  81.         'theme_location' => 'footer',
  82.         'container'      => false,
  83.         'depth'          => 1,
  84.         'fallback_cb'    => false,
  85.         'menu_class'     => 'genesis-nav-menu',
  86.     ) );
  87.    
  88.     echo '</nav>';
  89. }
  90.  
  91. //* Unregister layout settings
  92. genesis_unregister_layout( 'content-sidebar-sidebar' );
  93. genesis_unregister_layout( 'sidebar-content-sidebar' );
  94. genesis_unregister_layout( 'sidebar-sidebar-content' );
  95.  
  96. //* Unregister secondary sidebar
  97. unregister_sidebar( 'sidebar-alt' );
  98.  
  99. //* Add support for custom header
  100. add_theme_support( 'custom-header', array(
  101.     'flex-height'     => true,
  102.     'width'           => 360,
  103.     'height'          => 76,
  104.     'header-selector' => '.site-title a',
  105.     'header-text'     => false,
  106. ) );
  107.  
  108. //* Add support for structural wraps
  109. add_theme_support( 'genesis-structural-wraps', array(
  110.     'header',
  111.     'nav',
  112.     'subnav',
  113.     'footer-widgets',
  114.     'footer',
  115. ) );
  116.  
  117. //* Modify the size of the Gravatar in the author box
  118. add_filter( 'genesis_author_box_gravatar_size', 'altitude_author_box_gravatar' );
  119. function altitude_author_box_gravatar( $size ) {
  120.  
  121.     return 176;
  122.  
  123. }
  124.  
  125. //* Modify the size of the Gravatar in the entry comments
  126. add_filter( 'genesis_comment_list_args', 'altitude_comments_gravatar' );
  127. function altitude_comments_gravatar( $args ) {
  128.  
  129.     $args['avatar_size'] = 120;
  130.     return $args;
  131.  
  132. }
  133.  
  134. //* Remove comment form allowed tags
  135. add_filter( 'comment_form_defaults', 'altitude_remove_comment_form_allowed_tags' );
  136. function altitude_remove_comment_form_allowed_tags( $defaults ) {
  137.  
  138.     $defaults['comment_field'] = '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun', 'altitude' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>';
  139.     $defaults['comment_notes_after'] = ''; 
  140.     return $defaults;
  141.  
  142. }
  143.  
  144. //* Add support for after entry widget
  145. add_theme_support( 'genesis-after-entry-widget-area' );
  146.  
  147. //* Relocate after entry widget
  148. remove_action( 'genesis_after_entry', 'genesis_after_entry_widget_area' );
  149. add_action( 'genesis_after_entry', 'genesis_after_entry_widget_area', 5 );
  150.  
  151. //* Setup widget counts
  152. function altitude_count_widgets( $id ) {
  153.     global $sidebars_widgets;
  154.  
  155.     if ( isset( $sidebars_widgets[ $id ] ) ) {
  156.         return count( $sidebars_widgets[ $id ] );
  157.     }
  158.  
  159. }
  160.  
  161. function altitude_widget_area_class( $id ) {
  162.     $count = altitude_count_widgets( $id );
  163.  
  164.     $class = '';
  165.    
  166.     if( $count == 1 ) {
  167.         $class .= ' widget-full';
  168.     } elseif( $count % 3 == 1 ) {
  169.         $class .= ' widget-thirds';
  170.     } elseif( $count % 4 == 1 ) {
  171.         $class .= ' widget-fourths';
  172.     } elseif( $count % 2 == 0 ) {
  173.         $class .= ' widget-halves uneven';
  174.     } else {   
  175.         $class .= ' widget-halves';
  176.     }
  177.     return $class;
  178.    
  179. }
  180.  
  181. //* Relocate the post info
  182. remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
  183. add_action( 'genesis_entry_header', 'genesis_post_info', 5 );
  184.  
  185. //* Customize the entry meta in the entry header
  186. add_filter( 'genesis_post_info', 'altitude_post_info_filter' );
  187. function altitude_post_info_filter( $post_info ) {
  188.  
  189.     $post_info = '[post_date format="M d Y"] [post_edit]';
  190.     return $post_info;
  191.  
  192. }
  193.  
  194. //* Customize the entry meta in the entry footer
  195. add_filter( 'genesis_post_meta', 'altitude_post_meta_filter' );
  196. function altitude_post_meta_filter( $post_meta ) {
  197.  
  198.     $post_meta = 'Written by [post_author_posts_link] [post_categories before=" &middot; Categorized: "]  [post_tags before=" &middot; Tagged: "]';
  199.     return $post_meta;
  200.    
  201. }
  202.  
  203. //* Register widget areas
  204. genesis_register_sidebar( array(
  205.     'id'          => 'front-page-1',
  206.     'name'        => __( 'Front Page 1', 'altitude' ),
  207.     'description' => __( 'This is the front page 1 section.', 'altitude' ),
  208. ) );
  209. genesis_register_sidebar( array(
  210.     'id'          => 'front-page-2',
  211.     'name'        => __( 'Front Page 2', 'altitude' ),
  212.     'description' => __( 'This is the front page 2 section.', 'altitude' ),
  213. ) );
  214. genesis_register_sidebar( array(
  215.     'id'          => 'front-page-3',
  216.     'name'        => __( 'Front Page 3', 'altitude' ),
  217.     'description' => __( 'This is the front page 3 section.', 'altitude' ),
  218. ) );
  219. genesis_register_sidebar( array(
  220.     'id'          => 'front-page-4',
  221.     'name'        => __( 'Front Page 4', 'altitude' ),
  222.     'description' => __( 'This is the front page 4 section.', 'altitude' ),
  223. ) );
  224. genesis_register_sidebar( array(
  225.     'id'          => 'front-page-5',
  226.     'name'        => __( 'Front Page 5', 'altitude' ),
  227.     'description' => __( 'This is the front page 5 section.', 'altitude' ),
  228. ) );
  229. genesis_register_sidebar( array(
  230.     'id'          => 'front-page-6',
  231.     'name'        => __( 'Front Page 6', 'altitude' ),
  232.     'description' => __( 'This is the front page 6 section.', 'altitude' ),
  233. ) );
  234. genesis_register_sidebar( array(
  235.     'id'          => 'front-page-7',
  236.     'name'        => __( 'Front Page 7', 'altitude' ),
  237.     'description' => __( 'This is the front page 7 section.', 'altitude' ),
  238. ) );
  239.  
  240. //* header nav Search bar
  241.  
  242. add_filter( 'wp_nav_menu_items', 'theme_menu_extras', 10, 2 );
  243. /**
  244.  * Filter menu items, appending either a search form or today's date.
  245.  *
  246.  * @param string   $menu HTML string of list items.
  247.  * @param stdClass $args Menu arguments.
  248.  *
  249.  * @return string Amended HTML string of list items.
  250.  */
  251. function theme_menu_extras( $menu, $args ) {
  252.  
  253.     //* Change 'primary' to 'secondary' to add extras to the secondary navigation menu
  254.     if ( 'primary' !== $args->theme_location )
  255.         return $menu;
  256.  
  257.     //* Uncomment this block to add a search form to the navigation menu
  258.     /*
  259.     ob_start();
  260.     get_search_form();
  261.     $search = ob_get_clean();
  262.     $menu  .= '<li class="right search">' . $search . '</li>';
  263.     */
  264.  
  265.     //* Uncomment this block to add the date to the navigation menu
  266.     /*
  267.     $menu .= '<li class="right date">' . date_i18n( get_option( 'date_format' ) ) . '</li>';
  268.     */
  269.  
  270.     return $menu;
  271.  
  272. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement