feat(01-01): register custom post type for form submissions
- Created Umzugsliste_CPT class with singleton pattern - Registered umzugsliste_entry post type - German labels (Einträge, Eintrag) - Settings: public=false, show_ui=true, show_in_menu=false - Supports title field only (custom fields in Phase 6) - Registered on init hook
This commit is contained in:
71
includes/class-cpt.php
Normal file
71
includes/class-cpt.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* Custom Post Type Registration
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* CPT registration class
|
||||
*/
|
||||
class Umzugsliste_CPT {
|
||||
|
||||
/**
|
||||
* Single instance
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Get instance
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
private function __construct() {
|
||||
add_action( 'init', array( $this, 'register_post_type' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the custom post type
|
||||
*/
|
||||
public function register_post_type() {
|
||||
$labels = array(
|
||||
'name' => 'Einträge',
|
||||
'singular_name' => 'Eintrag',
|
||||
'menu_name' => 'Einträge',
|
||||
'name_admin_bar' => 'Eintrag',
|
||||
'add_new' => 'Neu hinzufügen',
|
||||
'add_new_item' => 'Neuen Eintrag hinzufügen',
|
||||
'new_item' => 'Neuer Eintrag',
|
||||
'edit_item' => 'Eintrag bearbeiten',
|
||||
'view_item' => 'Eintrag ansehen',
|
||||
'all_items' => 'Alle Einträge',
|
||||
'search_items' => 'Einträge durchsuchen',
|
||||
'not_found' => 'Keine Einträge gefunden',
|
||||
'not_found_in_trash' => 'Keine Einträge im Papierkorb gefunden',
|
||||
);
|
||||
|
||||
$args = array(
|
||||
'labels' => $labels,
|
||||
'public' => false,
|
||||
'show_ui' => true,
|
||||
'show_in_menu' => false,
|
||||
'capability_type' => 'post',
|
||||
'supports' => array( 'title' ),
|
||||
'has_archive' => false,
|
||||
'rewrite' => false,
|
||||
);
|
||||
|
||||
register_post_type( 'umzugsliste_entry', $args );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user