file = $file; self::$instance->version = get_plugin_data( self::$instance->file, false, false )['Version'] ?? ''; self::$instance->setup_constants(); self::$instance->includes(); self::$instance->hooks(); self::$instance->functions = new AffiliateWP_Affiliate_Info_Functions; } return self::$instance; } /** * Throw error on object clone * * The whole idea of the singleton design pattern is that there is a single * object therefore, we don't want the object to be cloned. * * @since 1.0 * @access protected * @return void */ public function __clone() { // Cloning instances of the class is forbidden _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'affiliatewp-affiliate-info' ), '1.0' ); } /** * Disable unserializing of the class * * @since 1.0 * @access protected * @return void */ public function __wakeup() { // Unserializing instances of the class is forbidden _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'affiliatewp-affiliate-info' ), '1.0' ); } /** * Constructor Function * * @since 1.0 * @access private */ private function __construct() { self::$instance = $this; } /** * Reset the instance of the class * * @since 1.0 * @access public * @static */ public static function reset() { self::$instance = null; } /** * Setup plugin constants * * @access private * @since 1.0 * @return void */ private function setup_constants() { // Plugin version if ( ! defined( 'AFFWP_AFFILIATE_INFO_VERSION' ) ) { define( 'AFFWP_AFFILIATE_INFO_VERSION', $this->version ); } // Plugin Folder Path if ( ! defined( 'AFFWP_AFFILIATE_INFO_PLUGIN_DIR' ) ) { define( 'AFFWP_AFFILIATE_INFO_PLUGIN_DIR', plugin_dir_path( $this->file ) ); } // Plugin Folder URL if ( ! defined( 'AFFWP_AFFILIATE_INFO_PLUGIN_URL' ) ) { define( 'AFFWP_AFFILIATE_INFO_PLUGIN_URL', plugin_dir_url( $this->file ) ); } // Plugin Root File if ( ! defined( 'AFFWP_AFFILIATE_INFO_PLUGIN_FILE' ) ) { define( 'AFFWP_AFFILIATE_INFO_PLUGIN_FILE', $this->file ); } } /** * Include necessary files * * @access private * @since 1.0.0 * @return void */ private function includes() { require_once AFFWP_AFFILIATE_INFO_PLUGIN_DIR . 'includes/class-shortcodes.php'; require_once AFFWP_AFFILIATE_INFO_PLUGIN_DIR . 'includes/class-functions.php'; } /** * Setup the default hooks and actions * * @since 1.0 * * @return void */ private function hooks() { // plugin meta add_filter( 'plugin_row_meta', array( $this, 'plugin_meta' ), null, 2 ); } /** * Modify plugin metalinks * * @access public * @since 1.0.0 * @since 1.2.0 Get more addons removed. * @param array $links The current links array * @param string $file A specific plugin table entry * @return array $links The modified links array */ public function plugin_meta( $links, $file ) { return $links; } } /** * The main function responsible for returning the one true AffiliateWP_Affiliate_Info * Instance to functions everywhere. * * Use this function like you would a global variable, except without needing * to declare the global. * * Example: * * @since 1.0.0 * @return object The one true AffiliateWP_Affiliate_Info Instance */ function affiliatewp_affiliate_info() { return AffiliateWP_Affiliate_Info::instance(); } }