Creating a WordPress Class with Backend and Frontend functionality

Firstly, a bare bones PHP class. Add this in it’s own file, eg mynewclass.php, and include it in functions.php

<?php
class MyNewClassName
{
	public function __construct()
	{

	}
}
$mynewclass=new MyNewClassName();
?>

Now a slightly more sophisticated one to add an admin menu item and page, with page tabs.

<?php
class MyNewClassName
{
	protected $admin_page_url;
	public function __construct()
	{
		$this->admin_page_url="my-new-class";
		add_action("admin_menu",array($this,"my_new_class_admin_menu"));
	}
	function my_new_class_admin_menu()
	{
		add_menu_page("My New Class","My New Class","manage_options",$this->admin_page_url,array($this,"my_new_class_page_contents"),"dashicons-schedule",3);
	}
	function my_new_class_page_contents()
	{
		$default_tab = 'general';
		$tab = isset($_GET['tab']) ? $_GET['tab'] : $default_tab;
		echo "<div class='wrap'>";
		echo "<h1>".esc_html( get_admin_page_title())."</h1>";
		echo '<nav class="nav-tab-wrapper">';
		?>
			<a href="?page=<?php echo $this->admin_page_url;?>&tab=general" class="nav-tab <?php if($tab==='general'):?>nav-tab-active<?php endif; ?>">General</a>
		<?php
   		echo '</nav>';
   		echo '<div class="tab-content">';
   		switch($tab) :
   			case 'general':
   				echo $this->general_tab();
   			break;
	    	default:

   			break;
   		endswitch;
   		echo '</div>';
	}
	function general_tab()
	{
		echo "<div>";
		echo "<p>hello world!</p>";
		echo "</div>";
	}
}
$mynewclass=new MyNewClassName();
?>