load_hooks(); } /** * Load initial hooks. */ private function load_hooks() { add_action( 'admin_notices', array( $this, 'notice_install_plugin' ) ); } /** * Show notification to install Gutenverse Plugin. */ public function notice_install_plugin() { // Skip if gutenverse block activated. $screen = get_current_screen(); if ( isset( $screen->parent_file ) && 'themes.php' === $screen->parent_file && 'appearance_page_{{slug}}-dashboard' === $screen->id ) { return; } if ( isset( $screen->parent_file ) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id ) { return; } if ( 'true' === get_user_meta( get_current_user_id(), 'gutenverse_install_notice', true ) ) { return; } $active_plugins = get_option( 'active_plugins' ); $plugins = array(); foreach( $active_plugins as $active ) { $plugins[] = explode( '/', $active)[0]; } $all_plugin = get_plugins(); $plugins_required = array( {{plugins_required}} ); $actions = array(); $count_plugin_active = 0; foreach ( $plugins_required as $plugin ) { $slug = $plugin['slug']; $path = "$slug/$slug.php"; $active = in_array($path, $active_plugins); if ( isset( $all_plugin[ $path ] ) ) { if ( $active ) { $actions[ $slug ] = 'active'; ++$count_plugin_active; } else { $actions[ $slug ] = 'inactive'; } } else { $actions[ $slug ] = ''; } } if ( count( $plugins_required ) === $count_plugin_active ) { return; } ?> {{dashboard_style}} {{dashboard_script}} {{dashboard_notice}} $plugin_data ) { $plugin_dir = dirname($plugin_file); if ($plugin_dir === $plugin_slug) { return true; } } return false; } }