Skip to content

Instantly share code, notes, and snippets.

@hirozed
Last active February 16, 2021 20:16
Show Gist options
  • Save hirozed/3e25eeacd6fb68facaac95d8fe21634c to your computer and use it in GitHub Desktop.
Save hirozed/3e25eeacd6fb68facaac95d8fe21634c to your computer and use it in GitHub Desktop.
WP Class Skeleton
<?php
/*
* [Class Title]
*/
class [className] {
/**
* Class Instance.
*
* @var object
*/
private static $instance;
/**
* Singleton method.
*/
public static function get_instance() {
if ( null === static::$instance ) {
static::$instance = new static();
}
return static::$instance;
}
/**
* Construction Method.
* Set up variables and add hooks
*/
protected function __construct() {
// Add WP hooks and calls to methods to be initialized
}
/**
* Clone Method.
*/
private function __clone() {
}
/**
* Wakeup Method.
*/
private function __wakeup() {
}
}
[className]::get_instance();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment