Advertisement
son86000

functions

Aug 2nd, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.18 KB | None | 0 0
  1. <?php
  2.  
  3. //Habilitando imagens destacadas
  4. add_theme_support('post-thumbnails');
  5. add_image_size('thumb-custom', 232, 156, true);
  6.  
  7. //Registro Custom Post Type Profissional
  8. add_action('init', 'videos_register');
  9. function videos_register(){
  10.   $labels = array(
  11.         'name' => _x('Videos', 'post type general name'),
  12.         'singular name' => _x('Videos', 'post type singular name'),
  13.         'add_new' => _x('Adicionar novo video', 'video'),
  14.         'add_new_item' => __('Adicionar novo'),
  15.         'edit_item' => __('Editar video'),
  16.         'new_item' => __('Novo video'),
  17.         'view_item' => __('Ver video'),
  18.         'search_video' => __('Procurar video'),
  19.         'not_found' => __('Nada encontrado'),
  20.         'not_found_in_trash' => __('Nada encontrado no lixo'),
  21.         'parent_item_colon' => ''
  22.     );
  23.  
  24.     $args = array(
  25.         'labels' => $labels,
  26.         'public' => true,
  27.         'publicity_querytable' => true,
  28.         'show_ui' => true,
  29.         'query_var' => true,
  30.         'rewrite' => true,
  31.         'has_archive' => false,
  32.         'capability_type' => 'post',
  33.         'hierarchical' => false,
  34.         'menu_position' => 4,
  35.         'supports' => array('title'),
  36.     );
  37.     register_post_type('videos',$args);
  38. }
  39. ?>
  40.  
  41. <?php //echo FrmFormsController::get_form_shortcode(
  42.       //array('id' => 2, 'key' => '', 'title' => false, 'readonly' => false,
  43.       //'entry_id' => false));
  44. ?>
  45.  
  46.  
  47.  
  48. <?php
  49. //breadcrumbs
  50. function wp_custom_breadcrumbs() {
  51.  
  52.   $showOnHome = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show
  53.   $delimiter = '&nbsp;/&nbsp;'; // delimiter between crumbs
  54.   $home = 'Home'; // text for the 'Home' link
  55.   $showCurrent = 1; // 1 - show current post/page title in breadcrumbs, 0 - don't show
  56.   $before = '<span class="current">'; // tag before the current crumb
  57.   $after = '</span>'; // tag after the current crumb
  58.  
  59.   global $post;
  60.   $homeLink = get_bloginfo('url');
  61.  
  62.   if (is_home() || is_front_page()) {
  63.  
  64.     if ($showOnHome == 1) echo '<div id="crumbs"><a href="' . $homeLink . '">' . $home . '</a></div>';
  65.  
  66.   } else {
  67.  
  68.     echo '<div id="crumbs"><a href="' . $homeLink . '">' . $home . '</a> ' . $delimiter . ' ';
  69.  
  70.     if ( is_category() ) {
  71.       $thisCat = get_category(get_query_var('cat'), false);
  72.       if ($thisCat->parent != 0) echo get_category_parents($thisCat->parent, TRUE, ' ' . $delimiter . ' ');
  73.       echo $before . 'categoria "' . single_cat_title('', false) . '"' . $after;
  74.  
  75.     } elseif ( is_search() ) {
  76.       echo $before . 'Search results for "' . get_search_query() . '"' . $after;
  77.  
  78.     } elseif ( is_day() ) {
  79.       echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
  80.       echo '<a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a> ' . $delimiter . ' ';
  81.       echo $before . get_the_time('d') . $after;
  82.  
  83.     } elseif ( is_month() ) {
  84.       echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
  85.       echo $before . get_the_time('F') . $after;
  86.  
  87.     } elseif ( is_year() ) {
  88.       echo $before . get_the_time('Y') . $after;
  89.  
  90.     } elseif ( is_single() && !is_attachment() ) {
  91.       if ( get_post_type() != 'post' ) {
  92.         $post_type = get_post_type_object(get_post_type());
  93.         $slug = $post_type->rewrite;
  94.         echo '<a href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a>';
  95.         if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
  96.       } else {
  97.         $cat = get_the_category(); $cat = $cat[0];
  98.         $cats = get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
  99.         if ($showCurrent == 0) $cats = preg_replace("#^(.+)\s$delimiter\s$#", "$1", $cats);
  100.         echo $cats;
  101.         if ($showCurrent == 1) echo $before . get_the_title() . $after;
  102.       }
  103.  
  104.     } elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) {
  105.       $post_type = get_post_type_object(get_post_type());
  106.       echo $before . $post_type->labels->singular_name . $after;
  107.  
  108.     } elseif ( is_attachment() ) {
  109.       $parent = get_post($post->post_parent);
  110.       $cat = get_the_category($parent->ID); $cat = $cat[0];
  111.       echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
  112.       echo '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a>';
  113.       if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
  114.  
  115.     } elseif ( is_page() && !$post->post_parent ) {
  116.       if ($showCurrent == 1) echo $before . get_the_title() . $after;
  117.  
  118.     } elseif ( is_page() && $post->post_parent ) {
  119.       $parent_id  = $post->post_parent;
  120.       $breadcrumbs = array();
  121.       while ($parent_id) {
  122.         $page = get_page($parent_id);
  123.         $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
  124.         $parent_id  = $page->post_parent;
  125.       }
  126.       $breadcrumbs = array_reverse($breadcrumbs);
  127.       for ($i = 0; $i < count($breadcrumbs); $i++) {
  128.         echo $breadcrumbs[$i];
  129.         if ($i != count($breadcrumbs)-1) echo ' ' . $delimiter . ' ';
  130.       }
  131.       if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
  132.  
  133.     } elseif ( is_tag() ) {
  134.       echo $before . 'Posts tagged "' . single_tag_title('', false) . '"' . $after;
  135.  
  136.     } elseif ( is_author() ) {
  137.        global $author;
  138.       $userdata = get_userdata($author);
  139.       echo $before . 'Articles posted by ' . $userdata->display_name . $after;
  140.  
  141.     } elseif ( is_404() ) {
  142.       echo $before . 'Error 404' . $after;
  143.     }
  144.  
  145.     if ( get_query_var('paged') ) {
  146.       if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' (';
  147.       echo __('Page') . ' ' . get_query_var('paged');
  148.       if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')';
  149.     }
  150.  
  151.     echo '</div>';
  152.  
  153.   }
  154. } // end wp_custom_breadcrumbs()
  155. ?>
  156.  
  157. <?php
  158. function novo_tamanho_do_resumo($length) {
  159.   return 30;
  160. }
  161. add_filter('excerpt_length', 'novo_tamanho_do_resumo');
  162.  
  163. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement