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 . '-details'; 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 !=='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(){ if ( file_exists( WP_PLUGIN_DIR . '/af-companion/af-companion.php' ) ) { if(is_plugin_active('af-companion/af-companion.php')){ $af_companion_title = __( 'Get Starter Sites', 'broadnews' ); $af_companion_url = site_url( ).'/wp-admin/admin.php?page=af-companion'; }else{ $af_companion_title = __( 'Activate AF Companion', 'broadnews' ); $af_companion_url = wp_nonce_url( 'plugins.php?action=activate&plugin=af-companion/af-companion.php&plugin_status=all&paged=1', 'activate-plugin_af-companion/af-companion.php' ); } }else{ $af_companion_title = __( 'Install AF Companion', 'broadnews' ); $af_companion_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=af-companion' ), 'install-plugin_af-companion' ); } $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/"; $notice_starter_msg =sprintf( '

%1$s

%2$s

', __( 'General info', 'broadnews' ), esc_html__( 'All of the features provided by the theme are now ready to use; Here, we have gathered all of the essential details and helpful links for you and your better experience with the theme. Once again, Thanks for using our theme!', 'broadnews' ), $af_companion_url, $af_companion_title, esc_url($demo_link), esc_html__('Demos/product','broadnews'), esc_url( admin_url() ."themes.php?page=".$this->page_slug ), esc_html__('Theme dashboard','broadnews') ); $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__( 'Return to your dashboard', '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();