wtkd

Functions.php

May 4th, 2011
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.84 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4.     Admin configuration
  5. */
  6. require_once ( TEMPLATEPATH . '/admin/include.php');
  7.  
  8. /*
  9.     Theme configuration
  10. */
  11. require_once ( TEMPLATEPATH . '/theme-panels/include.php');
  12.  
  13. /*
  14.     Ativar gerenciamento de menus [a partir da versão 3.0]
  15. */
  16. add_theme_support(
  17. 'menus' );
  18.  
  19. add_action('init', 'produto_register');
  20.  /* Post types */
  21. function produto_register() {
  22.  
  23.     $labels = array(
  24.         'name' => _x('Produto', 'post type general name'),
  25.         'singular_name' => _x('Produto Item', 'post type singular name'),
  26.         'add_new' => _x('Add New', 'produto item'),
  27.         'add_new_item' => __('Add New Produto Item'),
  28.         'edit_item' => __('Edit Produto Item'),
  29.         'new_item' => __('New Produto Item'),
  30.         'view_item' => __('View Produto Item'),
  31.         'search_items' => __('Search Produto'),
  32.         'not_found' =>  __('Nothing found'),
  33.         'not_found_in_trash' => __('Nothing found in Trash'),
  34.         'parent_item_colon' => ''
  35.     );
  36.  
  37.     $args = array(
  38.         'labels' => $labels,
  39.         'public' => true,
  40.         'publicly_queryable' => true,
  41.         'show_ui' => true,
  42.         'query_var' => true,
  43.         'menu_icon' => get_stylesheet_directory_uri() . '/article16.png',
  44.         'rewrite' => true,
  45.         'capability_type' => 'post',
  46.         'hierarchical' => false,
  47.         'menu_position' => null,
  48.         'supports' => array('title','editor','thumbnail')
  49.       );
  50.  
  51.     register_post_type( 'produto' , $args );
  52. }
  53. /* Taxonomia 'categoria de posts types' */
  54. register_taxonomy("down", array("produto"), array("hierarchical" => true, "label" => "down", "singular_label" => "down", "rewrite" => true));
  55.  
  56. /* adicionar campos de informação customizados no adicionar/editar post page. */
  57.  
  58. add_action("admin_init", "admin_init");
  59.  
  60. function admin_init(){
  61.   add_meta_box("modelo-meta", "Modelo", "modelo", "produto", "side", "low");
  62.   add_meta_box("descricao-meta", "descricao", "descricao", "produto", "normal", "low");
  63. }
  64.  
  65. function modelo(){
  66.   global $post;
  67.   $custom = get_post_custom($post->ID);
  68.   $modelo = $custom["modelo"][0];
  69.   ?>
  70.   <label>Modelo:</label>
  71.   <input name="modelo" value="<?php echo $modelo; ?>" />
  72.   <?php
  73. }
  74.  
  75. function descricao() {
  76.   global $post;
  77.   $custom = get_post_custom($post->ID);
  78.   $titulo = $custom["titulo"][0];
  79.   $texto = $custom["texto"][0];
  80.   $infotecnicas = $custom["infotecnicas"][0];
  81.   ?>
  82.   <p><label>Titulo:</label><br />
  83.   <textarea cols="50" rows="5" name="titulo"><?php echo $titulo; ?></textarea></p>
  84.   <p><label>Descri&ccedil;&atilde;o:</label><br />
  85.   <textarea cols="50" rows="5" name="texto"><?php echo $texto; ?></textarea></p>
  86.   <p><label>Informa&ccedil;&otilde;es Tecnicas:</label><br />
  87.   <textarea cols="50" rows="5" name="infotecnicas"><?php echo $infotecnicas; ?></textarea></p>
  88.   <?php
  89. }
  90. /* Salvando o conteudo preenchido */
  91. add_action('save_post', 'save_details');
  92.  
  93. function save_details(){
  94.   global $post;
  95.  
  96.   update_post_meta($post->ID, "modelo-meta", $_POST["modelo-meta"]);
  97.   update_post_meta($post->ID, "descricao-meta", $_POST["descricao-meta"]);
  98. }
  99. /* Salvando Colunas */
  100. add_action("manage_posts_custom_column",  "produto_custom_columns");
  101. add_filter("manage_edit-portfolio_columns", "produto_edit_columns");
  102.  
  103. function portfolio_edit_columns($columns){
  104.   $columns = array(
  105.     "cb" => "<input type=\"checkbox\" />",
  106.     "title" => "Produto Title",
  107.     "description" => "Description",
  108.     "modelo" => "modelo",
  109.     "down" => "down",
  110.   );
  111.  
  112.   return $columns;
  113. }
  114. function produto_custom_columns($column){
  115.   global $post;
  116.  
  117.   switch ($column) {
  118.     case "description":
  119.       the_excerpt();
  120.       break;
  121.     case "modelo-meta":
  122.       $custom = get_post_custom();
  123.       echo $custom["modelo"][0];
  124.       break;
  125.     case "down":
  126.       echo get_the_term_list($post->ID, 'down', '', ', ','');
  127.       break;
  128.   }
  129. }
  130.  
  131. ?>
Advertisement
Add Comment
Please, Sign In to add comment