theme = wp_get_theme(); $this->plugin_status = $this->get_plugin_status( 'omnipress/omnipress.php' ); if ( 'active' === $this->plugin_status ) { return; } add_action( 'admin_head', array( $this, 'notice_styles' ) ); add_action( 'init', array( $this, 'handle_dismiss_notice' ) ); if ( ! \get_transient( 'op_notice_dismissed' ) ) { add_action( 'admin_notices', array( $this, 'render_notice' ) ); } add_action( 'switch_theme', array( $this, 'show_notice' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'notice_scripts' ) ); } /** * Delete cookie on theme switch. * * @return void */ public function show_notice() { \delete_transient( 'op_notice_dismissed' ); } /** * Returns plugins status. * * @param string $plugin_slug * @return string active | paused | not-found */ protected function get_plugin_status( $plugin_slug ) { if ( ! function_exists( 'is_plugin_active' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } if ( is_plugin_active( $plugin_slug ) ) { return 'active'; } static $plugins = array(); if ( ! $plugins ) { $plugins = get_plugins(); } if ( isset( $plugins[ $plugin_slug ] ) ) { return 'paused'; } return 'not-found'; } public function notice_styles() { ?>

' . $this->theme->get( 'Name' ) . '' ); ?>

omnipress_url . '" target="_blank">Omnipress'; $text = sprintf( 'Explore the full potential of %1$s!
Get started by %2$s and access dozens of ready-to-use patterns and demos templates.', $this->theme->get( 'Name' ), 'paused' === $this->plugin_status ? "activating {$link}" : "installing {$link}" ); echo wp_kses_post( wpautop( $text ) ); } protected function _render_actions() { ?>
_render_title(); $this->_render_content(); $this->_render_actions(); ?>
', '' ), '', $scripts ) ); } /** * Dismiss notice. * * @return void */ public function handle_dismiss_notice(): void { if ( isset( $_POST['notice-dismiss'] ) ) { // phpcs:ignore set_transient( 'op_notice_dismissed', true, DAY_IN_SECONDS * 3 ); $redirect_url = esc_url( $_SERVER['REQUEST_URI'] ) ?? ''; sleep( 1 ); header( 'Location: ' . $redirect_url ); } } }