is_plugin_exist ( 'titan-framework/titan-framework.php' ) && !class_exists( 'TitanFramework' ) ) { if ( is_admin() ) { add_filter( 'admin_notices', array( $this, 'displayAdminNotificationNotExist' ) ); } } // If the plugin does exist but the class doesn't, the plugin is inactive. Throw admin notice to activate plugin. elseif ( $this->is_plugin_exist ( 'titan-framework/titan-framework.php' ) && !class_exists( 'TitanFramework' ) ) { if ( is_admin() ) { add_filter( 'admin_notices', array( $this, 'displayAdminNotificationInactive' ) ); } } // If the plugin exists and the class exists as well, or if the titan framework is embedded, as the class will exist from the start. else { return; } } /** * Displays a notification in the admin with a link to search * * @since 1.6 */ public function displayAdminNotificationNotExist() { echo "

" . __( "Titan Framework needs to be installed.", "default" ) . sprintf( " %s", admin_url( "plugin-install.php?tab=search&type=term&s=titan+framework" ), __( "Click here to search for the plugin.", "default" ) ) . "

"; } /** * Displays a notification in the admin if the Titan Framework is found but not activated. * * @since 1.6 */ public function displayAdminNotificationInactive() { echo "

" . __( "Titan Framework needs to be activated.", "default" ) . sprintf( " %s", admin_url( "plugins.php" ), __( "Click here to go to the plugins page and activate it.", "default" ) ) . "

"; } /** * Checks if the files for Titan Framework does exist in the path. * * @since 1.6 */ public function is_plugin_exist($needle) { // Required function as it is only loaded in admin pages. require_once ABSPATH . 'wp-admin/includes/plugin.php'; // Get all plugins, activated or not. $all_plugins = get_plugins(); // Check plugin existence by checking if the name is registered as an array key. get_plugins collects all plugin path into arrays. if ( isset($all_plugins[$needle]) ) { return true; } else { return false; } } } new TitanFrameworkChecker(); }