screenshot = get_template_directory_uri() . "/screenshot.png"; } else { $this->screenshot = get_stylesheet_directory_uri() . "/screenshot.png"; } $this->theme_name = $theme->get('Name'); $this->theme_slug = $theme->get_template(); $this->page_slug = $this->theme_slug; if (get_option($this->dismiss_notice_key) !== 'yes') { add_action('admin_notices', [$this, 'broadnews_admin_notice'], 0); add_action('wp_ajax_aft_notice_dismiss', [$this, 'broadnews_notice_dismiss']); } } function broadnews_admin_notice() { $current_screen = get_current_screen(); if ($current_screen->id != 'tools' && $current_screen->id != 'plugins' && $current_screen->id != 'options-general' && $current_screen->id !== 'dashboard' && $current_screen->id !== 'themes' && $current_screen->id !== 'appearance_page_af-dashbaord-details') { return; } if (defined('DOING_AJAX') && DOING_AJAX) { return; } if (is_network_admin()) { return; } if (! current_user_can('manage_options')) { return; } global $current_user; $user_id = $current_user->ID; $dismissed_notice = get_user_meta($user_id, $this->dismiss_notice_key, true); if ($dismissed_notice === 'dismissed') { update_option($this->dismiss_notice_key, 'yes'); } if (get_option($this->dismiss_notice_key, 'no') === 'yes') { return; } echo '
'; echo ''; $this->broadnews_dashboard_notice_content(); echo '
'; } function broadnews_dashboard_notice_content() { //$plugins = apply_filters('aft_plugins_for_starter_sites', array("blockspare", "templatespare", "elespare")); $plugins = apply_filters('aft_plugins_for_starter_sites', array("templatespare")); $install_plugin = []; $broadnews_templatespare_subtitle = ''; $activate_plugins = []; // $install_plugin = []; // $blocksapre_pro = 'blockspare-pro'; // $elepsare_pro = 'elespare-pro'; // $is_blockspare_pro = broadnews_get_plugin_file($blocksapre_pro); // $is_elespare_pro = broadnews_get_plugin_file($elepsare_pro); // $af_themes_info = new AF_themes_info(); // $check_blockspare = $af_themes_info->broadnews_check_blockspare_free_pro_activated(); // $check_elespare = $af_themes_info->broadnews_check_elespare_free_pro_activated(); // $broadnews_elementor_pro_installed = broadnews_get_plugin_file('elementor-pro'); // $broadnews_elementor_installed = broadnews_get_plugin_file('elementor'); // if ($check_blockspare == 'pro' && $is_blockspare_pro != null) { // unset($plugins[array_search('blockspare', $plugins)]); // array_push($plugins, $blocksapre_pro); // } // if ($check_elespare == 'pro' && $is_elespare_pro != null) { // unset($plugins[array_search('elespare', $plugins)]); // array_push($plugins, $elepsare_pro); // if (!empty($broadnews_elementor_pro_installed)) { // array_push($plugins, 'elementor-pro'); // } // if (!empty($broadnews_elementor_installed)) { // array_push($plugins, 'elementor'); // } else { // array_push($plugins, 'elementor'); // } // } // if (array_search('elespare', $plugins)) { // if (!empty($broadnews_elementor_pro_installed)) { // array_push($plugins, 'elementor-pro'); // } // if (!empty($broadnews_elementor_installed)) { // array_push($plugins, 'elementor'); // } else { // array_push($plugins, 'elementor'); // } // } if (!empty($plugins)) { foreach ($plugins as $key => $plugin) { $main_plugin_file = broadnews_get_plugin_file($plugin); // Get main plugin file if (!empty($main_plugin_file)) { if (!is_plugin_active($main_plugin_file)) { $btn_class = 'aft-bulk-active-plugin-installer'; $broadnews_templatespare_url = '#'; $activate_plugins[] = $plugin; } } else { $install_plugin[$key] = $plugin; $btn_class = 'aft-bulk-plugin-installer'; $broadnews_templatespare_url = "#"; } } } if (empty($activate_plugins) && empty($install_plugin)) { $btn_class = ''; $broadnews_templatespare_url = site_url() . '/wp-admin/admin.php?page=' . $this->page_slug; //$broadnews_templatespare_subtitle = __( 'The "Get Started" action will install/activate the AF Companion and Blockspare plugins for Starter Sites and Templates.', 'broadnews' ); $broadnews_templatespare_title = __('Get Starter Sites', 'broadnews'); } else { $btn_class = 'aft-bulk-active-plugin-installer'; $broadnews_templatespare_url = '#'; $broadnews_templatespare_title = __('Get Started', 'broadnews'); $broadnews_templatespare_subtitle = __('The "Get Started" action will install/activate the Templatespare and Blockspare plugins for Starter Sites and Templates.', 'broadnews'); } $main_template = '
%1$s
%2$s %3$s %4$s
'; $notice_header = sprintf( '

%1$s

%2$s

', esc_html__('Howdy!', 'broadnews'), sprintf( esc_html__('%s is now installed and ready to use. We\'ve assembled some links to get you started.', 'broadnews'), $this->theme_name ) ); $notice_picture = sprintf( '
', esc_url($this->screenshot) ); $demo_link = "https://afthemes.com/products/broadnews/#aft-view-starter-sites"; $notice_starter_msg = sprintf( '

%1$s

%2$s

', __('Explore Our Pre-Built Starter Websites!', 'broadnews'), esc_html__('Let your imagination soar! Designed with User-Friendly features, incorporating the Latest Trends and SEO-Friendly Markups. We genuinely appreciate you choosing our theme!', 'broadnews'), $broadnews_templatespare_url, $broadnews_templatespare_title, esc_url($demo_link), esc_html__('Demos/product', 'broadnews'), esc_url(admin_url() . "admin.php?page=" . $this->page_slug), esc_html__('Theme dashboard', 'broadnews'), esc_attr($btn_class), $broadnews_templatespare_subtitle, ); $notice_external_msg = sprintf( '

%1$s

%2$s

', __('Documentation', 'broadnews'), esc_html__('Please check our full documentation for detailed information on how to setup and customize the theme.', 'broadnews'), esc_html__('Docs', 'broadnews'), esc_html__('Videos', 'broadnews'), esc_html__('Blog', 'broadnews'), esc_html__('Rate This Theme', 'broadnews') ); echo sprintf( $main_template, $notice_header, $notice_picture, $notice_starter_msg, $notice_external_msg ); } public function broadnews_notice_dismiss() { if (! isset($_POST['nonce'])) { return; } $nonce = $_POST['nonce']; if (! wp_verify_nonce($nonce, 'aft_installer_nonce')) { return; } update_option($this->dismiss_notice_key, 'yes'); $json = array( 'status' => 'success' ); wp_send_json($json); wp_die(); } } $data = new AdminNotice();