This post describes the exact step to develop a custom WordPress plugin from scratch using Object-Oriented Programming.
Go to https://wppb.me/, fill the form and download your zip file
Edit the main file (plugin-name.php) and update texts like ‘description’ if you want
Create all custom post types, make sure that the custom post type title is not longer than 20 characters otherwise you will get an error ‘invalid post type’
function create_post_uni_lms_classes_std() {
register_post_type( 'uni_lms_classes',
array(
'labels' => array(
'name' => __('Classes','unilms'),
'singular_name' => __('Class','unilms'),
'add_new' => __('Add New','unilms'),
'add_new_item' => __('Add New Class','unilms'),
'edit' => __('Edit','unilms'),
'edit_item' => __('Edit Class','unilms'),
'new_item' => __('New Class','unilms'),
'view' => __('View','unilms'),
'view_item' => __('View Class','unilms'),
'search_items' => __('Search Classes','unilms'),
'not_found' => __('No Class found','unilms'),
'not_found_in_trash' => __('No Classes found in Trash','unilms'),
'parent' => __('Parent Class','unilms')
),
'public' => true,
'menu_position' => 15,
'supports' => array( 'title' ),
'taxonomies' => array( '' ),
'has_archive' => true,
'show_in_menu' => false
)
);
}
add_action( 'init', 'create_post_uni_lms_classes_std' );
Create a menu page for plugin settings or configurations by using add_menu_page() and add_submenu_page() functions
function uni_lms_admin_actions_std(){
add_menu_page(
__('Problems We Solve Enhancement', $this->plugin_name),
'Problems We Solve',
'edit_posts',
$this->plugin_name,
array( $this, 'display_dashboard_page' ),
'dashicons-admin-settings',
30
);
add_submenu_page(
$this->plugin_name,
__('Success Stories', $this->plugin_name),
'Success Stories', 'edit_posts',
'edit.php?post_type=success-stories'
);
}
add_action('admin_menu', 'uni_lms_admin_actions_std');