Skip to content

Instantly share code, notes, and snippets.

@ThomasDK81
Created October 23, 2018 07:45
Show Gist options
  • Save ThomasDK81/792309197e9e1171f0d21a3f1715f54e to your computer and use it in GitHub Desktop.
Save ThomasDK81/792309197e9e1171f0d21a3f1715f54e to your computer and use it in GitHub Desktop.
Posttype and all labels and messages
add_action( 'init', 'register_post_type' );
/**
* Register sites
*
* @link http://codex.wordpress.org/Function_Reference/register_post_type
*/
function register_post_type() {
$sites_labels = array(
'name' => __( 'Hjemmesider', 'infoland-crm' ),
'singular_name' => __( 'Hjemmeside', 'infoland-crm' ),
'add_new' => __( 'Tilføj ny', 'infoland-crm' ),
'add_new_item' => __( 'Tilføj ny hjemmeside', 'infoland-crm' ),
'edit_item' => __( 'Rediger hjemmeside', 'infoland-crm' ),
'new_item' => __( 'Ny hjemmeside', 'infoland-crm' ),
'view_item' => __( 'Vis hjemmeside', 'infoland-crm' ),
'view_items' => __( 'Vis hjemmesider', 'infoland-crm' ),
'search_items' => __( 'Søg hjemmesider', 'infoland-crm' ),
'not_found' => __( 'Ingen hjemmesider fundet.', 'infoland-crm' ),
'not_found_in_trash' => __( 'Ingen hjemmesider fundet i Papirkurven.', 'infoland-crm' ),
'parent_item_colon' => __( 'Forældre hjemmeside:', 'infoland-crm' ),
'all_items' => __( 'Alle hjemmesider', 'infoland-crm' ),
'archives' => __( 'Hjemmeside arkiver', 'infoland-crm' ),
'attributes' => __( 'Hjemmeside egenskaber', 'infoland-crm' ),
'insert_into_item' => __( 'Indsæt', 'infoland-crm' ),
'uploaded_to_this_item' => __( 'Uploadet til hjemmeside', 'infoland-crm' ),
'featured_image' => __( 'Hjemmeside logo', 'infoland-crm' ),
'set_featured_image' => __( 'Vælg hjemmeside logo', 'infoland-crm' ),
'remove_featured_image' => __( 'Fjern hjemmeside logo', 'infoland-crm' ),
'use_featured_image' => __( 'Brug som hjemmeside logo', 'infoland-crm' ),
'menu_name' => __( 'Hjemmesider', 'infoland-crm' ),
'filter_items_list' => __( 'Filtrer hjemmeside liste', 'infoland-crm' ),
'items_list_navigation' => __( 'Hjemmeside liste navigation', 'infoland-crm' ),
'items_list' => __( 'Hjemmeside liste', 'infoland-crm' ),
'name_admin_bar' => __( 'Hjemmeside', 'infoland-crm' )
);
$sites_args = array(
'labels' => $sites_labels,
'description' => __( 'Hjemmesider i CRM.', 'infoland-crm' ),
'public' => false,
'exclude_from_search' => true,
'publicly_queryable' => false,
'show_ui' => true,
'show_in_nav_menus' => false,
'show_in_menu' => true,
'show_in_admin_bar' => true,
'menu_position' => null,
'menu_icon' => 'data:image/svg+xml;base64,' . base64_encode( '<svg xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path fill="#a0a5aa" d="M15 1v-1h-15v15h1v1h15v-15h-1zM3 1h9v1h-9v-1zM1 1h1v1h-1v-1zM1 3h13v11h-13v-11z"></path></svg>' ),
'capability_type' => 'post',
'map_meta_cap' => null,
'hierarchical' => false,
'supports' => array( 'title', 'editor', 'revisions' ),
//'register_meta_box_cb' => "Provide a callback function that will be called when setting up the meta boxes for the edit form.",
//'taxonomies' => 'sites-groups',
'has_archive' => false,
'query_var' => true,
'can_export' => true,
'delete_with_user' => false,
'show_in_rest' => false,
//'rest_controller_class' => WP_REST_Posts_Controller
);
register_post_type( 'sites', $sites_args );
}
add_filter( 'post_updated_messages', function ( $messages ) {
global $post;
$messages['sites'] = array(
0 => '',
1 => __( 'Hjemmeside opdateret', 'infoland-crm' ),
2 => __( 'Brugerdefineret felt opdateret', 'infoland-crm' ),
3 => __( 'Brugerdefineret felt slettet', 'infoland-crm' ),
4 => __( 'Hjemmeside opdateret:', 'infoland-crm' ),
5 => isset( $_GET['revision'] ) ? sprintf( __( 'Hjemmeside genskabt til revision fra %s', 'infoland-crm' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => __( 'Hjemmeside udgivet', 'infoland-crm' ),
7 => __( 'Hjemmeside gemt', 'infoland-crm' ),
8 => __( 'Hjemmeside sendt til godkendelse', 'infoland-crm' ),
9 => sprintf( __( 'Hjemmeside planlagt til: <strong>%1$s</strong>.', 'infoland-crm' ), date_i18n( __( 'j. F Y @ H:i', 'infoland-crm' ), strtotime( $post->post_date ) ) ),
10 => __( 'Hjemmeside kladde opdateret.', 'infoland-crm' )
);
return $messages;
} );
add_filter( 'bulk_post_updated_messages', function ( $bulk_messages, $bulk_counts ) {
$bulk_messages['sites'] = array(
'updated' => _n( "%s hjemmeside opdateret.", "%s hjemmesider opdateret.", $bulk_counts["updated"] ),
'locked' => _n( "%s hjemmeside ikke opdateret, nogen rediger den.", "%s hjemmesider ikke opdateret, nogen rediger dem.", $bulk_counts["locked"] ),
'deleted' => _n( "%s hjemmeside slettet permanent.", "%s hjemmesider slettet permanent.", $bulk_counts["deleted"] ),
'trashed' => _n( "%s hjemmeside flyttet til papirkurv.", "%s hjemmesider flyttet til papirkurv.", $bulk_counts["trashed"] ),
'untrashed' => _n( "%s hjemmeside gendannet fra papirkurv.", "%s hjemmesider gendannet fra papirkurv.", $bulk_counts["untrashed"] ),
);
return $bulk_messages;
}, 10, 2 );
add_action('admin_head', 'codex_custom_help_tab');
function codex_custom_help_tab() {
$screen = get_current_screen();
// Return early if we're not on the book post type.
if ( 'book' != $screen->post_type )
return;
// Setup help tab args.
$args = array(
'id' => 'you_custom_id', //unique id for the tab
'title' => 'Custom Help', //unique visible title for the tab
'content' => '<h3>Help Title</h3><p>Help content</p>', //actual help text
);
// Add the help tab.
$screen->add_help_tab( $args );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment