Advertisement
srikat

Untitled

May 19th, 2016
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.94 KB | None | 0 0
  1. <?php
  2. /* ==========================================================================
  3. * Theme Setup
  4. * ========================================================================== */
  5.  
  6. //* Start the engine
  7. include_once( get_template_directory() . '/lib/init.php' );
  8.  
  9. //* Setup Theme
  10. include_once( get_stylesheet_directory() . '/lib/theme-defaults.php' );
  11.  
  12. //* Page Header
  13. include_once( get_stylesheet_directory() . '/lib/page-header.php' );
  14.  
  15. //* Testimonials
  16. include_once( get_stylesheet_directory() . '/lib/testimonials.php' );
  17. include_once( get_stylesheet_directory() . '/lib/widget-testimonials.php' );
  18.  
  19. //* Team
  20. include_once( get_stylesheet_directory() . '/lib/team.php' );
  21. include_once( get_stylesheet_directory() . '/lib/widget-team.php' );
  22.  
  23. //* Add Image upload and Color select to WordPress Theme Customizer
  24. require_once( get_stylesheet_directory() . '/lib/customize.php' );
  25.  
  26. //* Include Customizer CSS
  27. include_once( get_stylesheet_directory() . '/lib/output.php' );
  28.  
  29. //* Child theme (do not remove)
  30. define( 'CHILD_THEME_NAME', 'Showcase Pro' );
  31. define( 'CHILD_THEME_URL', 'http://my.studiopress.com/themes/showcase/' );
  32. define( 'CHILD_THEME_VERSION', '1.0.2' );
  33.  
  34. //* Enqueue scripts and styles
  35. add_action( 'wp_enqueue_scripts', 'showcase_scripts_styles' );
  36. function showcase_scripts_styles() {
  37.  
  38. wp_enqueue_style( 'google-fonts', '//fonts.googleapis.com/css?family=Hind:400,300,500,600,700', array(), CHILD_THEME_VERSION );
  39. wp_enqueue_style( 'ionicons', '//code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css', array(), CHILD_THEME_VERSION );
  40.  
  41. wp_enqueue_script( 'showcase-fitvids', get_stylesheet_directory_uri() . '/js/jquery.fitvids.js', array(), CHILD_THEME_VERSION );
  42. wp_enqueue_script( 'showcase-global', get_stylesheet_directory_uri() . '/js/global.js', array(), CHILD_THEME_VERSION );
  43. wp_enqueue_script( 'showcase-responsive-menu', get_stylesheet_directory_uri() . '/js/responsive-menu.js', array(), CHILD_THEME_VERSION );
  44.  
  45. if ( is_front_page() ) {
  46. wp_enqueue_style( 'bxslider', get_stylesheet_directory_uri() . '/css/bxslider.css' );
  47. wp_enqueue_script( 'showcase-bxslider', get_stylesheet_directory_uri() . '/js/jquery.bxslider.min.js', array(), CHILD_THEME_VERSION );
  48. }
  49.  
  50. }
  51.  
  52. //* Add HTML5 markup structure
  53. add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) );
  54.  
  55. //* Add accessibility support
  56. add_theme_support( 'genesis-accessibility', array( '404-page', 'drop-down-menu', 'headings', 'search-form', 'skip-links' ) );
  57.  
  58. add_theme_support( 'genesis-structural-wraps', array(
  59. 'header',
  60. 'subnav',
  61. 'site-inner',
  62. 'footer-widgets',
  63. 'footer'
  64. ) );
  65.  
  66. //* Add screen reader class to archive description
  67. add_filter( 'genesis_attr_author-archive-description', 'genesis_attributes_screen_reader_class' );
  68.  
  69. //* Add viewport meta tag for mobile browsers
  70. add_theme_support( 'genesis-responsive-viewport' );
  71.  
  72. /* ==========================================================================
  73. * Header
  74. * ========================================================================== */
  75.  
  76. //* Add support for custom header
  77. add_theme_support( 'custom-header', array(
  78. 'width' => 400,
  79. 'height' => 150,
  80. 'header-selector' => '.site-title a',
  81. 'header-text' => false,
  82. 'flex-height' => true,
  83. ) );
  84.  
  85. //* Assign the correct class for white or transparent header
  86. $header_color = get_option( 'showcase_header_color', 'true' );
  87. if ( $header_color === 'white' ) {
  88.  
  89. add_filter( 'body_class', 'showcase_header_color_class' );
  90. function showcase_header_color_class( $classes ) {
  91.  
  92. $classes[] = 'white-header';
  93. return $classes;
  94.  
  95. }
  96. }
  97.  
  98. //* Add Image Sizes
  99. add_image_size( 'showcase_featured_posts', 600, 400, TRUE );
  100. add_image_size( 'showcase_archive', 900, 500, TRUE );
  101. add_image_size( 'showcase_team_thumb', 600, 800, TRUE );
  102. add_image_size( 'showcase_hero', 1920, 960, TRUE );
  103.  
  104.  
  105. /* ==========================================================================
  106. * Navigation
  107. * ========================================================================== */
  108.  
  109. //* Rename primary and secondary navigation menus
  110. add_theme_support ( 'genesis-menus' , array ( 'primary' => __( 'Header Menu', 'showcase' ), 'secondary' => __( 'Page Header Menu', 'showcase' ) ) );
  111.  
  112. //* Reposition primary navigation menu
  113. remove_action( 'genesis_after_header', 'genesis_do_nav' );
  114. add_action( 'genesis_header', 'genesis_do_nav', 12 );
  115.  
  116. //* Remove output of primary navigation right extras
  117. remove_filter( 'genesis_nav_items', 'genesis_nav_right', 10, 2 );
  118. remove_filter( 'wp_nav_menu_items', 'genesis_nav_right', 10, 2 );
  119.  
  120. //* Remove secondary navigation menu, it's added back in the /lib/page-header.php
  121. remove_action( 'genesis_after_header', 'genesis_do_subnav' );
  122.  
  123. //* Reduce secondary navigation menu to one level depth
  124. add_filter( 'wp_nav_menu_args', 'showcase_secondary_menu_args' );
  125. function showcase_secondary_menu_args( $args ){
  126.  
  127. if( 'secondary' != $args['theme_location'] )
  128. return $args;
  129.  
  130. $args['depth'] = 1;
  131. return $args;
  132.  
  133. }
  134.  
  135. //* Remove navigation meta box
  136. add_action( 'genesis_theme_settings_metaboxes', 'showcase_remove_genesis_metaboxes' );
  137. function showcase_remove_genesis_metaboxes( $_genesis_theme_settings_pagehook ) {
  138.  
  139. remove_meta_box( 'genesis-theme-settings-nav', $_genesis_theme_settings_pagehook, 'main' );
  140.  
  141. }
  142.  
  143. /* ==========================================================================
  144. * Widget Areas
  145. * ========================================================================== */
  146.  
  147. //* Add support for after entry widget
  148. add_theme_support( 'genesis-after-entry-widget-area' );
  149.  
  150. //* Add support for shortcodes in widget areas
  151. add_filter('widget_text', 'do_shortcode');
  152.  
  153. //* Remove header right widget area
  154. unregister_sidebar( 'header-right' );
  155.  
  156. //* Remove secondary sidebar
  157. unregister_sidebar( 'sidebar-alt' );
  158.  
  159. //* Remove site layouts
  160. genesis_unregister_layout( 'content-sidebar-sidebar' );
  161. genesis_unregister_layout( 'sidebar-content-sidebar' );
  162. genesis_unregister_layout( 'sidebar-sidebar-content' );
  163.  
  164. //* Setup widget counts
  165. function showcase_count_widgets( $id ) {
  166.  
  167. global $sidebars_widgets;
  168.  
  169. if ( isset( $sidebars_widgets[ $id ] ) ) {
  170. return count( $sidebars_widgets[ $id ] );
  171. }
  172.  
  173. }
  174.  
  175. //* Flexible widget classes
  176. function showcase_widget_area_class( $id ) {
  177.  
  178. $count = showcase_count_widgets( $id );
  179.  
  180. $class = '';
  181.  
  182. if( $count == 1 ) {
  183. $class .= ' widget-full';
  184. } elseif( $count % 3 == 1 ) {
  185. $class .= ' widget-thirds';
  186. } elseif( $count % 4 == 1 ) {
  187. $class .= ' widget-fourths';
  188. } elseif( $count % 2 == 0 ) {
  189. $class .= ' widget-halves uneven';
  190. } else {
  191. $class .= ' widget-halves even';
  192. }
  193. return $class;
  194.  
  195. }
  196.  
  197. //* Flexible widget classes
  198. function showcase_halves_widget_area_class( $id ) {
  199.  
  200. $count = showcase_count_widgets( $id );
  201.  
  202. $class = '';
  203.  
  204. if( $count == 1 ) {
  205. $class .= ' widget-full';
  206. } elseif( $count % 2 == 0 ) {
  207. $class .= ' widget-halves';
  208. } else {
  209. $class .= ' widget-halves uneven';
  210. }
  211. return $class;
  212.  
  213. }
  214.  
  215. //* Register widget areas
  216. genesis_register_sidebar( array(
  217. 'id' => 'front-page-hero',
  218. 'name' => __( 'Front Page Hero', 'showcase' ),
  219. 'description' => __( 'This is the page header section on the front page.', 'showcase' ),
  220. ) );
  221. genesis_register_sidebar( array(
  222. 'id' => 'front-page-1',
  223. 'name' => __( 'Front Page 1', 'showcase' ),
  224. 'description' => __( 'This is the 1st section on the front page.', 'showcase' ),
  225. ) );
  226. genesis_register_sidebar( array(
  227. 'id' => 'front-page-2',
  228. 'name' => __( 'Front Page 2', 'showcase' ),
  229. 'description' => __( 'This is the 2nd section on the front page.', 'showcase' ),
  230. ) );
  231. genesis_register_sidebar( array(
  232. 'id' => 'front-page-3',
  233. 'name' => __( 'Front Page 3', 'showcase' ),
  234. 'description' => __( 'This is the 3rd section on the front page.', 'showcase' ),
  235. ) );
  236. genesis_register_sidebar( array(
  237. 'id' => 'front-page-4',
  238. 'name' => __( 'Front Page 4', 'showcase' ),
  239. 'description' => __( 'This is the 4th section on the front page.', 'showcase' ),
  240. ) );
  241. genesis_register_sidebar( array(
  242. 'id' => 'before-footer',
  243. 'name' => __( 'Before Footer', 'showcase' ),
  244. 'description' => __( 'This is a widget area right before the footer on every page.', 'showcase' ),
  245. ) );
  246.  
  247. //* Add the Before Footer Widget Area
  248. add_action( 'genesis_before_footer', 'showcase_before_footer_widget_area', 5 );
  249. function showcase_before_footer_widget_area() {
  250. if ( is_active_sidebar( 'before-footer' ) ) {
  251. genesis_widget_area( 'before-footer', array(
  252. 'before' => '<div id="before-footer" class="before-footer"><div class="wrap"><div class="widget-area' . showcase_widget_area_class( 'before-footer' ) . '">',
  253. 'after' => '</div></div></div>',
  254. ) );
  255. }
  256. }
  257.  
  258. //* Add support for 4-column footer widget
  259. add_theme_support( 'genesis-footer-widgets', 4 );
  260.  
  261.  
  262. /* ==========================================================================
  263. * Blog Related
  264. * ========================================================================== */
  265.  
  266. //* Reposition entry meta in entry header
  267. remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
  268. add_action( 'genesis_entry_header', 'genesis_post_info', 8 );
  269.  
  270. //* Customize entry meta in the entry header
  271. add_filter( 'genesis_post_info', 'showcase_entry_meta_header' );
  272. function showcase_entry_meta_header($post_info) {
  273.  
  274. $post_info = '[post_categories before="" after=" &middot;"] [post_date] [post_edit before=" &middot; "]';
  275. return $post_info;
  276.  
  277. }
  278.  
  279. //* Customize the content limit more markup
  280. add_filter( 'get_the_content_limit', 'showcase_content_limit_read_more_markup', 10, 3 );
  281. function showcase_content_limit_read_more_markup( $output, $content, $link ) {
  282.  
  283. $output = sprintf( '<p>%s &#x02026;</p><p>%s</p>', $content, str_replace( '&#x02026;', '', $link ) );
  284.  
  285. return $output;
  286.  
  287. }
  288.  
  289. //* Modify the Genesis content limit read more link
  290. add_filter( 'get_the_content_more_link', 'showcase_read_more_link' );
  291. function showcase_read_more_link() {
  292. return '<a class="more-link" href="' . get_permalink() . '">Continue Reading</a>';
  293. }
  294.  
  295. //* Customize author box title
  296. add_filter( 'genesis_author_box_title', 'showcase_author_box_title' );
  297. function showcase_author_box_title() {
  298.  
  299. return '<span itemprop="name">' . get_the_author() . '</span>';
  300.  
  301. }
  302.  
  303. //* Modify size of the Gravatar in the author box
  304. add_filter( 'genesis_author_box_gravatar_size', 'showcase_author_box_gravatar' );
  305. function showcase_author_box_gravatar( $size ) {
  306.  
  307. return 160;
  308.  
  309. }
  310.  
  311. //* Remove entry meta in the entry footer on category pages
  312. add_action( 'genesis_before_entry', 'showcase_remove_entry_footer' );
  313. function showcase_remove_entry_footer() {
  314.  
  315. if ( is_front_page() || is_archive() || is_search() || is_home() || is_page_template( 'page_blog.php' ) ) {
  316.  
  317. remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 );
  318. remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
  319. remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );
  320.  
  321. }
  322.  
  323. }
  324.  
  325. //* Display author box on single posts
  326. add_filter( 'get_the_author_genesis_author_box_single', '__return_true' );
  327.  
  328.  
  329. /* ==========================================================================
  330. * Helper Functions
  331. * ========================================================================== */
  332.  
  333. /**
  334. * Bar to Line Break
  335. *
  336. */
  337. function showcase_bar_to_br( $content ) {
  338. return str_replace( ' | ', '<br class="mobile-hide">', $content );
  339. }
  340.  
  341. // Enqueue Scripts and Styles
  342. add_action( 'wp_enqueue_scripts', 'sk_enqueue_scripts_styles' );
  343. function sk_enqueue_scripts_styles() {
  344.  
  345. // Make Font Awesome available
  346. wp_enqueue_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css' );
  347.  
  348. // Load global.js before </body>
  349. // wp_enqueue_script( 'global', get_stylesheet_directory_uri() . '/js/global.js', array( 'jquery' ), CHILD_THEME_VERSION, true );
  350.  
  351. }
  352.  
  353. add_filter( 'wp_nav_menu_items', 'sk_gf_link', 10, 2 );
  354. /**
  355. * Filter menu items, appending a link for slide toggling Gravity Forms form.
  356. *
  357. * @param string $menu HTML string of list items.
  358. * @param stdClass $args Menu arguments.
  359. *
  360. * @return string Amended HTML string of list items.
  361. */
  362. function sk_gf_link( $menu, $args ) {
  363.  
  364. // Change 'primary' to 'secondary' to add extras to the secondary navigation menu
  365. if ( 'primary' !== $args->theme_location )
  366. return $menu;
  367.  
  368. $menu .= '<li class="right nav-form-dropdown"><a href="#" id="nav-form-toggle">Get A Quote<i class="fa fa-chevron-circle-down">&nbsp;</i></a><div id="nav-form-holder">' . do_shortcode( '[gravityform id="1" title="false" description="true" ajax="true"]' ) . '</div></li>';
  369.  
  370. return $menu;
  371.  
  372. }
  373.  
  374. // Enable Field Label Visibility Settings in Gravity Forms
  375. add_filter( 'gform_enable_field_label_visibility_settings', '__return_true' );
  376.  
  377. // Disable auto scrolling to anchor after form submission
  378. add_filter( 'gform_confirmation_anchor_1', '__return_false' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement