;. */ class GamiPress_Activation_Addon { function __construct() { // Define plugin constants $this->basename = plugin_basename( __FILE__ ); $this->directory_path = plugin_dir_path( __FILE__ ); $this->directory_url = plugins_url( 'gamipress-activation-addon/' ); // Load translations load_plugin_textdomain( 'gamipress-activation-addon', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); // Run our activation register_activation_hook( __FILE__, array( $this, 'activate' ) ); // If GamiPress is unavailable, deactivate our plugin add_action( 'admin_notices', array( $this, 'maybe_disable_plugin' ) ); add_action( 'plugins_loaded', array( $this, 'includes' ) ); add_action( 'wp_print_scripts', array( $this, 'enqueue_scripts' ) ); } /** * Files to include for GamiPress integration. * * @since 1.0.0 */ public function includes() { if ( $this->meets_requirements() ) { require_once( $this->directory_path . '/includes/actions-filters.php' ); } } /** * Enqueue custom scripts and styles * * @since 1.0.0 */ public function enqueue_scripts() { } /** * Activation hook for the plugin. * * @since 1.0.0 */ public function activate() { // If GamiPress is available, run our activation functions if ( $this->meets_requirements() ) { $this->includes(); } } /** * Check if GamiPress is available * * @since 1.0.0 * @return bool True if GamiPress is available, false otherwise */ public static function meets_requirements() { if ( class_exists('GamiPress') ) { return true; } else { return false; } } /** * Generate a custom error message and deactivates the plugin if we don't meet requirements * * @since 1.0.0 */ public function maybe_disable_plugin() { if ( ! $this->meets_requirements() ) { // Display our error echo '
' . sprintf( __( 'GamiPress Activation Add-On requires GamiPress and has been deactivated. Please install and activate GamiPress and then reactivate this plugin.', 'gamipress-activation-addon' ), admin_url( 'plugins.php' ) ) . '
'; echo '