| Server IP : 65.108.144.40 / Your IP : 216.73.217.165 Web Server : Apache/2.4.52 (Ubuntu) System : Linux ubuntu-8gb-hel1-1 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64 User : dev ( 1000) PHP Version : 8.2.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/successkpi/wp-content/themes/successkpi/inc/classes/ |
Upload File : |
<?php
/**
* Base Class for Custom Post Types
* Follows OOP architecture for dynamic registration.
*/
class CustomPostType
{
public static $postType = '';
public static $nameSingular = '';
public static $namePlural = '';
public static $slug = '';
public static $hasArchive = true;
public static $menuPosition = null;
public static $icon = 'dashicons-admin-post';
public static $supports = array('title', 'editor', 'thumbnail', 'excerpt', 'revisions');
public static $taxonomies = array();
public function __construct()
{
add_action('init', array($this, 'register_post_type'));
}
public function register_post_type()
{
if (empty(static::$postType)) return;
$labels = array(
'name' => static::$namePlural,
'singular_name' => static::$nameSingular,
'menu_name' => static::$namePlural,
'name_admin_bar' => static::$nameSingular,
'add_new' => 'Add New',
'add_new_item' => 'Add New ' . static::$nameSingular,
'new_item' => 'New ' . static::$nameSingular,
'edit_item' => 'Edit ' . static::$nameSingular,
'view_item' => 'View ' . static::$nameSingular,
'all_items' => 'All ' . static::$namePlural,
'search_items' => 'Search ' . static::$namePlural,
'parent_item_colon' => 'Parent ' . static::$namePlural . ':',
'not_found' => 'No ' . strtolower(static::$namePlural) . ' found.',
'not_found_in_trash' => 'No ' . strtolower(static::$namePlural) . ' found in Trash.'
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array('slug' => static::$slug),
'capability_type' => 'post',
'has_archive' => static::$hasArchive,
'hierarchical' => false,
'menu_position' => static::$menuPosition,
'show_in_rest' => true,
'menu_icon' => static::$icon,
'taxonomies' => static::$taxonomies,
'supports' => static::$supports
);
register_post_type(static::$postType, $args);
}
}