functions.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <?php
  2. // remover versao do wordpress
  3. remove_action('wp_head', 'wp_generator');
  4. // CONSTANTES
  5. define('THEMEROOT', get_stylesheet_directory_uri());
  6. define('IMAGES', THEMEROOT . '/img');
  7. define('JS', THEMEROOT . '/js');
  8. // theme setup
  9. if(! function_exists('tuts_theme_setup')) {
  10. function tuts_theme_setup() {
  11. // fazendo o tema disponivel para traducao
  12. $lang_dir = THEMEROOT . '/languages';
  13. load_theme_textdomain('tuts', $$lang_dir);
  14. // adicionando suporte automatico a feed links
  15. add_theme_support('automatic-feed-link');
  16. // adicionando suporte a post-thumbnails
  17. add_theme_support( 'post-thumbnails' );
  18. // registar os menus
  19. register_nav_menus(
  20. array(
  21. 'main-menu' => __( 'Main Menu', 'tuts' ),
  22. 'extra-menu' => __( 'Extra Menu', 'tuts' )
  23. )
  24. );
  25. }
  26. add_action('after_setup_theme', 'tuts_theme_setup');
  27. }
  28. // get post meta data
  29. if(! function_exists('tuts_post_meta')) {
  30. function tuts_post_meta() {
  31. if(get_post_type() === 'post') {
  32. echo '<p class="post-meta">';
  33. _e('by','tuts');
  34. printf('<a href="%1$s" rel="author"> %2$s </a>', esc_url( get_author_posts_url( get_the_author_meta('ID') )), get_the_author() );
  35. _e('on','tuts');
  36. echo '<span> '. get_the_date() .'</span></p>';
  37. // <p class="post-meta">
  38. // by <a href="#">Cory Simmons</a> on <span>November 15th, 2014</span>
  39. // </p>
  40. }
  41. }
  42. }
  43. // carregar os numeros de paginacao
  44. // https://codex.wordpress.org/Function_Reference/paginate_links
  45. if(! function_exists('tuts_numbered_pagination')) {
  46. function tuts_numbered_pagination() {
  47. $args = array(
  48. 'prev_next' => false,
  49. 'type' => 'array'
  50. );
  51. echo '<div class="col-md-12">';
  52. $pagination = paginate_links( $args );
  53. if(is_array( $pagination )) {
  54. echo '<ul class="nav nav-pills">';
  55. foreach($pagination as $page) {
  56. if(strpos( $page, 'current' )) {
  57. echo '<li class="active"><a href="#">' . $page . '</a></li>';
  58. } else {
  59. echo '<li>'. $page .'</li>';
  60. }
  61. }
  62. echo '</ul>';
  63. }
  64. echo '</div>';
  65. // <div class="col-md-12">
  66. // <ul class="nav nav-pills">
  67. // <li role="presentation" class="active"><a href="#">1</a></li>
  68. // <li role="presentation"><a href="#">2</a></li>
  69. // <li role="presentation"><a href="#">3</a></li>
  70. // </ul>
  71. // </div>
  72. }
  73. }
  74. // registar widget areas
  75. if(! function_exists('tuts_widget_init')) {
  76. function tuts_widget_init() {
  77. if(function_exists('register_sidebar')) {
  78. register_sidebar( array(
  79. 'name' => __( 'Main Widget Area', 'tuts' ),
  80. 'id' => 'main-sidebar',
  81. 'description' => __( 'Appears in the blog pages.', 'tuts' ),
  82. 'before_widget' => '<div id="%1$s" class="widget %2$s">',
  83. 'after_widget' => '</div>',
  84. 'before_title' => '<h2>',
  85. 'after_title' => '</h2>',
  86. ) );
  87. }
  88. }
  89. add_action('widgets_init','tuts_widget_init');
  90. }
  91. // registar e enfilerar scripts
  92. if(! function_exists('tuts_scripts')) {
  93. function tuts_scripts() {
  94. // registar script
  95. wp_register_script('modernizr-js', JS . '/vendor/modernizr-2.6.2.min.js', false, false, false);
  96. wp_register_script('bootstrap-js', THEMEROOT . '/bower_components/bootstrap/dist/js/bootstrap.min.js', array('jquery'), false, true);
  97. wp_register_script('isotope-js', THEMEROOT . '/bower_components/isotope/dist/isotope.pkgd.min.js', false, false, true);
  98. wp_register_script('plugins-js', JS . '/plugins.js', false, false, true);
  99. wp_register_script('main-js', JS . '/main.js', false, false, true);
  100. // carregar os scripts
  101. wp_enqueue_script('modernizr-js');
  102. wp_enqueue_script('bootstrap-js');
  103. wp_enqueue_script('isotope-js');
  104. wp_enqueue_script('plugins-js');
  105. wp_enqueue_script('main-js');
  106. // carregar os stylecss
  107. wp_enqueue_style('bootstrap-css', THEMEROOT . '/bower_components/bootstrap/dist/css/bootstrap.min.css');
  108. wp_enqueue_style('main-css', THEMEROOT . '/css/style.css');
  109. }
  110. add_action('wp_enqueue_scripts','tuts_scripts');
  111. }
  112. // widgets
  113. require_once ( get_template_directory() . '/include/widgets/widget-recent-projects.php');
  114. // rvalidar o comprimento
  115. if ( ! function_exists( 'tuts_validate_length' ) ) {
  116. function tuts_validate_length( $fieldValue, $minLength ) {
  117. return ( strlen( trim( $fieldValue ) ) > $minLength );
  118. }
  119. }
  120. ?>