Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Admin configuration
- */
- require_once ( TEMPLATEPATH . '/admin/include.php');
- /*
- Theme configuration
- */
- require_once ( TEMPLATEPATH . '/theme-panels/include.php');
- /*
- Ativar gerenciamento de menus [a partir da versão 3.0]
- */
- add_theme_support(
- 'menus' );
- add_action('init', 'produto_register');
- /* Post types */
- function produto_register() {
- $labels = array(
- 'name' => _x('Produto', 'post type general name'),
- 'singular_name' => _x('Produto Item', 'post type singular name'),
- 'add_new' => _x('Add New', 'produto item'),
- 'add_new_item' => __('Add New Produto Item'),
- 'edit_item' => __('Edit Produto Item'),
- 'new_item' => __('New Produto Item'),
- 'view_item' => __('View Produto Item'),
- 'search_items' => __('Search Produto'),
- 'not_found' => __('Nothing found'),
- 'not_found_in_trash' => __('Nothing found in Trash'),
- 'parent_item_colon' => ''
- );
- $args = array(
- 'labels' => $labels,
- 'public' => true,
- 'publicly_queryable' => true,
- 'show_ui' => true,
- 'query_var' => true,
- 'menu_icon' => get_stylesheet_directory_uri() . '/article16.png',
- 'rewrite' => true,
- 'capability_type' => 'post',
- 'hierarchical' => false,
- 'menu_position' => null,
- 'supports' => array('title','editor','thumbnail')
- );
- register_post_type( 'produto' , $args );
- }
- /* Taxonomia 'categoria de posts types' */
- register_taxonomy("down", array("produto"), array("hierarchical" => true, "label" => "down", "singular_label" => "down", "rewrite" => true));
- /* adicionar campos de informação customizados no adicionar/editar post page. */
- add_action("admin_init", "admin_init");
- function admin_init(){
- add_meta_box("modelo-meta", "Modelo", "modelo", "produto", "side", "low");
- add_meta_box("descricao-meta", "descricao", "descricao", "produto", "normal", "low");
- }
- function modelo(){
- global $post;
- $custom = get_post_custom($post->ID);
- $modelo = $custom["modelo"][0];
- ?>
- <label>Modelo:</label>
- <input name="modelo" value="<?php echo $modelo; ?>" />
- <?php
- }
- function descricao() {
- global $post;
- $custom = get_post_custom($post->ID);
- $titulo = $custom["titulo"][0];
- $texto = $custom["texto"][0];
- $infotecnicas = $custom["infotecnicas"][0];
- ?>
- <p><label>Titulo:</label><br />
- <textarea cols="50" rows="5" name="titulo"><?php echo $titulo; ?></textarea></p>
- <p><label>Descrição:</label><br />
- <textarea cols="50" rows="5" name="texto"><?php echo $texto; ?></textarea></p>
- <p><label>Informações Tecnicas:</label><br />
- <textarea cols="50" rows="5" name="infotecnicas"><?php echo $infotecnicas; ?></textarea></p>
- <?php
- }
- /* Salvando o conteudo preenchido */
- add_action('save_post', 'save_details');
- function save_details(){
- global $post;
- update_post_meta($post->ID, "modelo-meta", $_POST["modelo-meta"]);
- update_post_meta($post->ID, "descricao-meta", $_POST["descricao-meta"]);
- }
- /* Salvando Colunas */
- add_action("manage_posts_custom_column", "produto_custom_columns");
- add_filter("manage_edit-portfolio_columns", "produto_edit_columns");
- function portfolio_edit_columns($columns){
- $columns = array(
- "cb" => "<input type=\"checkbox\" />",
- "title" => "Produto Title",
- "description" => "Description",
- "modelo" => "modelo",
- "down" => "down",
- );
- return $columns;
- }
- function produto_custom_columns($column){
- global $post;
- switch ($column) {
- case "description":
- the_excerpt();
- break;
- case "modelo-meta":
- $custom = get_post_custom();
- echo $custom["modelo"][0];
- break;
- case "down":
- echo get_the_term_list($post->ID, 'down', '', ', ','');
- break;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment