Last active
February 20, 2023 11:25
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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