functions.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <?php
  2. add_action('genesis_setup','genesischild_theme_setup', 15);
  3. function genesischild_theme_setup() {
  4. $estilos_genesis_do_pai = 'estilo-genesis-pai';
  5. // wp_enqueue_style($estilos_genesis_do_pai, get_template_directory_uri() . '/style.css');
  6. //Add support for HTML5 markup
  7. add_theme_support( 'html5' );
  8. //Add viewport metatag
  9. add_theme_support( 'genesis-responsive-viewport' );
  10. //Criou nesta aula esta lista - genesis-footer-widgets - Add 3 footer widgets
  11. add_theme_support( 'genesis-footer-widgets', 3 );
  12. //Add support for custom background
  13. add_theme_support( 'custom-background' );
  14. // Adicionando suporte ao custom-header
  15. add_theme_support( 'custom-header', array(
  16. 'default-image' => get_stylesheet_directory_uri() . '/images/logo-genesis.png',
  17. 'header-selector' => '.site-title a',
  18. 'header-text' => false,
  19. 'height' => 115,
  20. 'width' => 300
  21. ));
  22. add_image_size('footer', 50, 50, true);
  23. //* Activate the use of Dashicons
  24. add_action( 'wp_enqueue_scripts', 'load_dashicons_front_end' );
  25. function load_dashicons_front_end() {
  26. wp_enqueue_style( 'dashicons' );
  27. }
  28. //* Enqueue scripts for Responsive menu
  29. add_action( 'wp_enqueue_scripts', 'enqueue_responsive_menu_script' );
  30. function enqueue_responsive_menu_script() {
  31. wp_enqueue_script( 'my-responsive-menu', get_stylesheet_directory_uri() . '/js/responsive-menu.js', array( 'jquery' ), '1.0.0' );
  32. }
  33. // trocando o menu secundario para outro lugar
  34. remove_action('genesis_after_header', 'genesis_do_subnav');
  35. // remove_action('genesis_after_header', 'genesis_do_nav');
  36. add_action('genesis_after_footer', 'genesis_do_subnav');
  37. // add_action('genesis_header_right', 'genesis_do_nav');
  38. // registrar widgets
  39. function extra_widgets() {
  40. genesis_register_sidebar( array(
  41. 'id' => 'sobre1',
  42. 'name' => 'Área de sobre 1',
  43. 'description' => 'Area de widgets para sobre 1',
  44. 'before_widget' => '<div class="sobre one-third first">',
  45. 'after_widget' => '</div>'
  46. ) );
  47. genesis_register_sidebar( array(
  48. 'id' => 'sobre2',
  49. 'name' => 'Área de sobre 2',
  50. 'description' => 'Area de widgets para sobre 2',
  51. 'before_widget' => '<div class="sobre one-third">',
  52. 'after_widget' => '</div>'
  53. ) );
  54. genesis_register_sidebar( array(
  55. 'id' => 'sobre3',
  56. 'name' => 'Área de sobre 3',
  57. 'description' => 'Area de widgets para sobre 3',
  58. 'before_widget' => '<div class="sobre one-third">',
  59. 'after_widget' => '</div><div class="clearfix"></div>'
  60. ) );
  61. genesis_register_sidebar( array(
  62. 'id' => 'copyright',
  63. 'name' => 'Área de Copyright',
  64. 'description' => 'Area de Copyright',
  65. 'before_widget' => '<div class="copyright wrap">',
  66. 'after_widget' => '</div></div>'
  67. ) );
  68. genesis_register_sidebar( array(
  69. 'id' => 'pesquisa',
  70. 'name' => 'Área de pesquisa',
  71. 'description' => 'Area de pesquisa',
  72. 'before_widget' => '<div class="pesquisa one-fourth">',
  73. 'after_widget' => '</div></div>'
  74. ) );
  75. }
  76. add_action('widgets_init', 'extra_widgets');
  77. }
  78. function meufilho_scripts() {
  79. // chamando o template css depois do style.css do pai, pois como é em cascata vai sobrepor regras do pai
  80. // wp_enqueue_style('template', get_stylesheet_directory_uri() . '/css/template.css', array('estilo-genesis-pai'), null, 'all');
  81. // desliguei e copie o style.css do curso, pois a versao do genesis2.5.2 estava usando e dando erro, no curso usa a 2.5.0
  82. // no curso o jeito que ele importa o css e copiando o conteudo do style.css do pai e colando o no filho.
  83. wp_enqueue_style('template', get_stylesheet_directory_uri() . '/css/template.css', array(), null, 'all');
  84. // flexslider
  85. wp_enqueue_style('flexslider', get_stylesheet_directory_uri() . '/flexslider/flexslider.css', array(), null, 'all');
  86. wp_enqueue_script('flexslider-js', get_stylesheet_directory_uri() . '/flexslider/flexslider.js', array('jquery'), null, false);
  87. wp_enqueue_script('flexslider-jsmin', get_stylesheet_directory_uri() . '/flexslider/jquery.flexslider-min.js', array('jquery'), null, false);
  88. wp_enqueue_style('font-awesome', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css', array(), null, 'all');
  89. }
  90. add_action('wp_enqueue_scripts', 'meufilho_scripts');
  91. add_filter('genesis_footer_creds_text', 'meufilho_copyright_filtro');
  92. function meufilho_copyright_filtro(){
  93. ob_start();
  94. dynamic_sidebar('copyright');
  95. $sidebar = ob_get_contents();
  96. ob_end_clean();
  97. return $sidebar;
  98. }
  99. function add_search_box () {
  100. genesis_widget_area('pesquisa', array(
  101. 'before' => '<div class="caixa-pesquisa"><div class="wrap">',
  102. 'after' => '</div></div>'
  103. ));
  104. }
  105. add_action('genesis_before_header', 'add_search_box');
  106. // adicionando o slider no mesmo hook do menu, assim a prioridade ter que ser maior que a do menu pra ficar depois do menu
  107. add_action('genesis_after_header', 'meuslider', 15);
  108. function meuslider(){
  109. if(is_front_page()):
  110. ?>
  111. <section class="slide">
  112. <div class="flexslider">
  113. <ul class="slides">
  114. <?php
  115. $query = new WP_Query( 'posts_per_page=4&ignore_sticky_posts=true' );
  116. if( $query->have_posts() ) : while( $query->have_posts() ) : $query->the_post();
  117. ?>
  118. <li>
  119. <div class="slider-container">
  120. <?php
  121. // If we have a thumbnail, show it
  122. // If not, we show a placeholder image
  123. if( has_post_thumbnail() ):
  124. ?>
  125. <figure>
  126. <?php the_post_thumbnail('large'); ?> <!-- Tem que incluir isso aqui! -->
  127. </figure>
  128. <?php else: ?>
  129. <img class="img-responsive" src="https://unsplash.it/1920/650/?random" title="<?php echo esc_attr_x( 'Placeholder Image', 'title', 'parea' ); ?>">
  130. <?php endif; ?>
  131. <div class="wrap">
  132. <div class="slider-details-container">
  133. <div class="slider-title">
  134. <h3><a href="<?php the_permalink(); ?>" class="slider-title"><?php the_title();?></a></h3>
  135. </div>
  136. <div class="slider-description">
  137. <?php the_excerpt(); ?>
  138. </div>
  139. <div class="slider-readmore-button">
  140. <a href="<?php the_permalink(); ?>" class="btn"><?php echo _e( 'Read More!', 'parea' ) ?></a>
  141. </div>
  142. </div>
  143. </div>
  144. </div>
  145. </li>
  146. <?php
  147. endwhile;
  148. wp_reset_postdata();
  149. endif;
  150. ?>
  151. </ul>
  152. </div>
  153. </section>
  154. <?php
  155. endif;
  156. }