Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.09 KB | None | 0 0
  1. <?php
  2. if (!defined('ABSPATH'))
  3. exit;
  4.  
  5. function anetema_styles() {
  6. wp_enqueue_script('site_funcoes', get_template_directory_uri() . '/js/funcoes.js', array('jquery'), null, true);
  7.  
  8. wp_enqueue_style('style', get_template_directory_uri() . '/style.css', false, null);
  9. }
  10.  
  11. add_action('wp_enqueue_scripts', 'anetema_styles', 100);
  12.  
  13. if (function_exists('add_theme_support')) {
  14. add_theme_support('post-thumbnails');
  15. set_post_thumbnail_size(195, 183, true);
  16. }
  17.  
  18. add_action( 'init', 'register_my_menus' );
  19. function register_my_menus() {
  20. register_nav_menus(
  21. array(
  22. 'topo' => 'Topo'
  23. )
  24. );
  25. }
  26.  
  27. if (!function_exists('anetema_post')) {
  28. function anetema_post($load = false) {
  29. global $post;
  30.  
  31. $thumb = get_the_post_thumbnail_url($post->ID, 'post-thumbnail');
  32. if (empty($thumb))
  33. $thumb = 'https://placehold.it/244x137';
  34.  
  35. $arrCategorias = wp_get_post_categories($post->ID);
  36.  
  37. $categoriaNome = '';
  38. $categoriaUrl = '';
  39. if (isset($arrCategorias[0])) {
  40. $categoriaNome = get_cat_name($arrCategorias[0]);
  41. $categoriaUrl = get_category_link($arrCategorias[0]);
  42. } ?>
  43.  
  44. <li>
  45. <a href="<?php echo get_permalink($post->ID); ?>" title="<?php echo $post->post_title; ?>">
  46. <img class="lista-imagem" src="<?php echo $thumb; ?>" alt="<?php echo $post->post_title; ?>" />
  47. </a>
  48.  
  49. <h3>
  50. <a href="<?php echo get_permalink($post->ID); ?>" title="<?php echo $post->post_title; ?>"><?php echo $post->post_title; ?></a>
  51. </h3>
  52.  
  53. <div class="entry-meta">
  54. <a class="lista-autor" href="<?php echo site_url('?author=1'); ?>"><?php echo get_the_author_meta('display_name', $post->post_author); ?></a> - <span class="lista-data"><?php echo get_the_date('j \d\e F \d\e Y'); ?></span>
  55. </div>
  56.  
  57. <div class="lista-texto"><?php echo short_desc($post->post_content); ?></div>
  58. </li>
  59. <?php
  60. }
  61. }
  62.  
  63. if (!function_exists('anetema_pagination')) {
  64. function anetema_pagination() {
  65. if (is_singular())
  66. return;
  67.  
  68. global $wp_query;
  69.  
  70. if( $wp_query->max_num_pages <= 1 )
  71. return;
  72.  
  73. $paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
  74. $max = intval( $wp_query->max_num_pages );
  75.  
  76. if ( $paged >= 1 )
  77. $links[] = $paged;
  78.  
  79. if ( $paged >= 3 ) {
  80. $links[] = $paged - 1;
  81. $links[] = $paged - 2;
  82. }
  83.  
  84. if ( ( $paged + 2 ) <= $max ) {
  85. $links[] = $paged + 2;
  86. $links[] = $paged + 1;
  87. }
  88.  
  89. echo '<ul class="paginacao">' . "\n";
  90.  
  91. if ( get_previous_posts_link() )
  92. printf( '<li>%s</li>' . "\n", get_previous_posts_link('«') );
  93.  
  94. if ( ! in_array( 1, $links ) ) {
  95. $class = 1 == $paged ? ' class="current"' : '';
  96.  
  97. printf( '<li><a %s rel="nofollow" href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
  98.  
  99. if ( ! in_array( 2, $links ) )
  100. echo '<li>…</li>';
  101. }
  102.  
  103. sort( $links );
  104. foreach ((array) $links as $link) {
  105. $class = $paged == $link ? ' class="current"' : '';
  106. printf( '<li><a %s rel="nofollow" href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
  107. }
  108.  
  109. if (get_next_posts_link())
  110. printf( '<li>%s</li>' . "\n", get_next_posts_link('Mais') );
  111.  
  112. echo '</ul>' . "\n";
  113. }
  114. }
  115.  
  116. function anetema_register_sidebars() {
  117. register_sidebar(
  118. array(
  119. 'id' => 'lateral',
  120. 'name' => 'Lateral',
  121. 'before_widget' => '<section id="%1$s" class="widget %2$s"><div class="widget-container">',
  122. 'after_widget' => '</div></section>',
  123. 'before_title' => '<div class="widget-title"><h4>',
  124. 'after_title' => '</h4></div>'
  125. )
  126. );
  127. }
  128.  
  129. add_action('widgets_init', 'anetema_register_sidebars');
  130.  
  131. function anetema_comment($comment, $args, $depth) {
  132. $GLOBALS['comment'] = $comment; ?>
  133. <!--inicio lista-->
  134.  
  135. <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
  136. <!--inicio comentario campo-->
  137. <div id="comment-<?php comment_ID(); ?>" class="comentario-campo">
  138.  
  139. <!-- avatar comentario -->
  140. <div class="avatar-comentario">
  141. <?php echo get_avatar( $comment, 74 ); ?>
  142. </div>
  143. <!-- fim avatar comentario -->
  144.  
  145. <!--inicio comentario e nome-->
  146. <div class="comentario-nome">
  147. <!--inicio nome comentarista-->
  148. <div class="nome-comentarista">
  149. <?php printf(__('%s'), get_comment_author_link())?> •
  150. <span class="data-comentario"> <?php echo get_comment_date('j \d\e F \d\e Y'); ?> </span>
  151. </div>
  152. <!--fim nome comentarista-->
  153.  
  154. <div class="clear"></div>
  155.  
  156. <!--inicio texto comentario-->
  157. <div class="texto-comentario">
  158. <?php comment_text() ?>
  159.  
  160. <div class="clear"></div>
  161.  
  162. <div class="reply-link">
  163. <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
  164. </div>
  165. </div>
  166. <!--fim texto comentario-->
  167. </div>
  168. <!--fim comentario e nome-->
  169. </div>
  170. </li>
  171. <?php
  172. }
  173.  
  174. if (!function_exists('short_desc')) {
  175. function short_desc($text = '', $tam = 108) {
  176.  
  177. $text = strip_shortcodes($text);
  178. $text = preg_replace('/<[^<]+?>/i', ' ', $text);
  179.  
  180. if (strlen($text) > $tam) {
  181. $text = preg_replace("/^(.{1,$tam})(\s.*|$)/s", '\\1...', $text);
  182. }
  183.  
  184. return $text;
  185. }
  186. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement