load_textdomain(); self::$instance->includes(); } return self::$instance; } /** * Throw error on object clone * * @since 2.0.0 * @access protected * @return void */ public function __clone() { // Cloning instance of the class is forbidden _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'affiliatewp-store-credit' ), '2.0.0' ); } /** * Disable unserializing of the class * * @since 2.0.0 * @access protected * @return void */ public function __wakeup() { // Unserializing instances of the class is forbidden _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'affiliatewp-store-credit' ), '2.0.0' ); } /** * Loads the plugin language files * * @since 0.1 * @access public * @return void */ public function load_textdomain() { // Set filter for plugin language directory $lang_dir = dirname( plugin_basename( __FILE__ ) ) . '/languages/'; $lang_dir = apply_filters( 'affiliatewp_store_credit_languages_directory', $lang_dir ); // Traditional WordPress plugin locale filter $locale = apply_filters( 'plugin_locale', get_locale(), 'affiliatewp-store-credit' ); $mofile = sprintf( '%1$s-%2$s.mo', 'affiliatewp-store-credit', $locale ); // Setup paths to current locale file $mofile_local = $lang_dir . $mofile; $mofile_global = WP_LANG_DIR . '/affiliatewp-store-credit/' . $mofile; if( file_exists( $mofile_global ) ) { // Look in global /wp-content/languages/affiliatewp-store-credit/ folder load_textdomain( 'affiliatewp-store-credit', $mofile_global ); } elseif( file_exists( $mofile_local ) ) { // Look in local /wp-content/plugins/affiliatewp-store-credit/ folder load_textdomain( 'affiliatewp-store-credit', $mofile_local ); } else { // Load the default language files load_plugin_textdomain( 'affiliatewp-store-credit', false, $lang_dir ); } } /** * Include required files * * @since 2.0.0 * @access private * @return void */ private function includes() { if( is_admin() ) { require_once self::$plugin_dir . 'admin/settings.php'; } // Check that store credit is enabled if( ! affiliate_wp()->settings->get( 'store-credit' ) ) { return; } require_once self::$plugin_dir . 'integrations/class-base.php'; // Load the class for each integration enabled foreach( affiliate_wp()->integrations->get_enabled_integrations() as $filename => $integration ) { if( file_exists( self::$plugin_dir . 'integrations/class-' . $filename . '.php' ) ) { require_once self::$plugin_dir . 'integrations/class-' . $filename . '.php'; } } } } /** * The main function responsible for returning the one true AffiliateWP_Store_Credit * instance to functions everywhere * * @since 2.0.0 * @return object The one true AffiliateWP_Store_Credit instance */ function affiliatewp_store_credit() { if( ! function_exists( 'affiliate_wp' ) ) { return; } return AffiliateWP_Store_Credit::instance(); } add_action( 'plugins_loaded', 'affiliatewp_store_credit', 100 );