Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save somewherewarm-snippets/ee3d68b9bfb56232fdd94a2edbcfd25e to your computer and use it in GitHub Desktop.
Save somewherewarm-snippets/ee3d68b9bfb56232fdd94a2edbcfd25e to your computer and use it in GitHub Desktop.
Boilerplate of a singleton controller for adding custom fixes into the WooCommerce Calypso Bridge plugin
<?php
/**
* Custom fix controller class.
*
* @package WC_Calypso_Bridge/Classes
* @since x.x.x
* @version x.x.x
*/
defined( 'ABSPATH' ) || exit;
if ( class_exists( 'WC_Calypso_Bridge_My_Custom_Fix' ) ) {
return
}
/**
* WC_Calypso_Bridge_My_Custom_Fix Class.
*/
class WC_Calypso_Bridge_My_Custom_Fix {
/**
* Class instance.
*/
protected static $instance = false;
/**
* Get class instance.
*/
final public static function get_instance() {
if ( ! self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor.
*/
public function __construct() {
// Plan detection.
// e.g. runs in business sites only.
// if ( ! wc_calypso_bridge_is_business_plan() ) {
// return;
// }
$this->init();
}
/**
* Initialize hooks.
*/
public function init() {
// Your code here. e.g., add_action( 'init', ... );
}
}
WC_Calypso_Bridge_My_Custom_Fix::get_instance();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment