Last active
June 8, 2016 17:59
-
-
Save brunohaveroth/363bf85aa3acc05a2ce5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************** Custom Post contact ****************************/ | |
function custom_post_contact() { | |
$labels = array( | |
'name' => _x( 'contacts', 'post type general name' ), | |
'singular_name' => _x( 'contact', 'post type singular name' ), | |
'add_new' => _x( 'Adicionar Nova contact', 'contact' ), | |
'add_new_item' => __( 'Nova contact' ), | |
'edit_item' => __( 'Editar contact' ), | |
'new_item' => __( 'Nova contact' ), | |
'all_items' => __( 'Todas as contacts' ), | |
'view_item' => __( 'Ver contact' ), | |
'search_items' => __( 'Procurar contact' ), | |
'not_found' => __( 'Nenhuma contact encontrada' ), | |
'not_found_in_trash' => __( 'Nenhuma contact na Lixeira' ), | |
'parent_item_colon' => '', | |
'menu_name' => 'contacts' | |
); | |
$args = array( | |
'labels' => $labels, | |
'description' => 'Guarda os dados da contact específica.', | |
'public' => true, | |
'menu_position' => 5, | |
'supports' => array('title', 'thumbnail'), | |
'has_archive' => true, | |
'taxonomies' => array( 'contact_category', 'contact_tag'), | |
); | |
register_post_type( 'contact', $args ); | |
} | |
add_action( 'init', 'custom_post_contact' ); | |
function update_mensagens_contact( $messages ) { | |
global $post, $post_ID; | |
$messages['contact'] = array( | |
0 => '', | |
1 => sprintf( __('contact atualizada. <a href="%s">Ver contact'), esc_url( get_permalink($post_ID) ) ), | |
2 => __('Campo personalizado atualizado.'), | |
3 => __('Campo personalizado excluído.'), | |
4 => __('contact atualizada.'), | |
5 => isset($_GET['revision']) ? sprintf( __('Restaura contact para revisão de %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, | |
6 => sprintf( __('contact publicada. <a href="%s">Ver contact'), esc_url( get_permalink($post_ID) ) ), | |
7 => __('contact salva.'), | |
8 => sprintf( __('contact enviada. <a target="_blank" href="%s">Visualizar contact'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), | |
9 => sprintf( __('contact agendada por: %1$s. <a target="_blank" href="%2$s">Visualizar contact'), date_i18n( __( 'd/m/Y ás G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ), | |
10 => sprintf( __('Rascunho da contact atualizado. <a target="_blank" href="%s">Visualizar contact'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), | |
); | |
return $messages; | |
} | |
add_filter( 'post_updated_messages', 'update_mensagens_contact' ); | |
function ajuda_contextual_contact( $contextual_help, $screen_id, $screen ) { | |
if ( 'contact' == $screen->id ) { | |
$contextual_help = '<h2>contacts</h2> | |
<p>Coloque aqui a descrição do que publicar nesse tipo de post. Vai aparecer na guia Ajuda no painel do WordPress.</p>'; | |
} | |
elseif ( 'edit-contact' == $screen->id ) { | |
$contextual_help = '<h2>Editando contacts</h2> | |
<p>E aqui, instruções sobre a edição dos posts do tipo personalizado.</p>'; | |
} | |
return $contextual_help; | |
} | |
add_action( 'contextual_help', 'ajuda_contextual_contact', 10, 3 ); | |
function custom_loop_contact( $query ) { | |
if ( is_home() && $query->is_main_query() ) | |
$query->set( 'post_type', array( 'post', 'contact') ); | |
return $query; | |
} | |
add_filter( 'pre_get_posts', 'custom_loop_contact' ); | |
/*********************************************************************************/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment