'', 'file' => '', 'label' => '', ); $args = wp_parse_args( $args, $defaults ); $slug = sanitize_key( $args['slug'] ); $file = sanitize_text_field( $args['file'] ); $label = sanitize_text_field( $args['label'] ); // Already active? if ( $file && bongoto_admin_is_plugin_active( $file ) ) { return '' . esc_html__( 'Active', 'bongoto-woocommerce' ) . ''; } // Check if installed. if ( ! function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $installed_plugins = get_plugins(); $is_installed = false; foreach ( $installed_plugins as $plugin_path => $plugin_data ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable if ( 0 === strpos( $plugin_path, $slug . '/' ) ) { $is_installed = true; $file = $plugin_path; // best-guess main file break; } } if ( $is_installed && $file ) { // Activate link. $url = wp_nonce_url( add_query_arg( array( 'action' => 'activate', 'plugin' => $file, ), admin_url( 'plugins.php' ) ), 'activate-plugin_' . $file ); return '' . esc_html__( 'Activate', 'bongoto-woocommerce' ) . ''; } // Install link. $url = wp_nonce_url( add_query_arg( array( 'action' => 'install-plugin', 'plugin' => $slug, ), admin_url( 'update.php' ) ), 'install-plugin_' . $slug ); return '' . esc_html__( 'Install', 'bongoto-woocommerce' ) . ''; } } /** * Add Welcome page under Appearance. */ function bongoto_admin_add_welcome_page() { add_theme_page( __( 'Bongoto Welcome', 'bongoto-woocommerce' ), __( 'Bongoto Welcome', 'bongoto-woocommerce' ), 'manage_options', 'bongoto-welcome', 'bongoto_admin_render_welcome_page' ); } add_action( 'admin_menu', 'bongoto_admin_add_welcome_page' ); /** * Dismissible notice (per-user). */ function bongoto_admin_welcome_notice() { if ( ! current_user_can( 'manage_options' ) ) { return; } $user_id = get_current_user_id(); if ( get_user_meta( $user_id, 'bongoto_dismiss_welcome', true ) ) { return; // dismissed } $dismiss_url = wp_nonce_url( add_query_arg( array( 'bongoto_dismiss_welcome' => 1 ) ), 'bongoto_dismiss_welcome' ); echo '
'; echo '

' . esc_html__( 'Thanks for installing Bongoto — WooCommerce Marketplace Theme!', 'bongoto-woocommerce' ) . ' '; echo esc_html__( 'Get started by installing recommended plugins or opening the Customizer.', 'bongoto-woocommerce' ) . '

'; echo '

' . esc_html__( 'Open Welcome', 'bongoto-woocommerce' ) . ' '; echo '' . esc_html__( 'Open Customizer', 'bongoto-woocommerce' ) . '

'; // Extra manual dismiss link in case auto-dismiss fails. echo '

' . esc_html__( 'Dismiss this notice', 'bongoto-woocommerce' ) . '

'; echo '
'; } add_action( 'admin_notices', 'bongoto_admin_welcome_notice' ); /** * Handle notice dismiss. */ function bongoto_admin_handle_notice_dismiss() { $nonce = isset( $_GET['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_GET['_wpnonce'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( isset( $_GET['bongoto_dismiss_welcome'] ) && wp_verify_nonce( $nonce, 'bongoto_dismiss_welcome' ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended update_user_meta( get_current_user_id(), 'bongoto_dismiss_welcome', 1 ); wp_safe_redirect( remove_query_arg( array( 'bongoto_dismiss_welcome', '_wpnonce' ) ) ); exit; } } add_action( 'admin_init', 'bongoto_admin_handle_notice_dismiss' ); /** * Render Welcome screen. */ function bongoto_admin_render_welcome_page() { if ( ! current_user_can( 'manage_options' ) ) { return; } // Recommended plugins (no seller/vendor plugin). $reco = array( array( 'slug' => 'woocommerce', 'file' => 'woocommerce/woocommerce.php', 'label' => 'WooCommerce', 'desc' => __( 'Core shop features: products, cart, checkout, My Account.', 'bongoto-woocommerce' ), ), array( 'slug' => 'elementor', 'file' => 'elementor/elementor.php', 'label' => 'Elementor', 'desc' => __( 'Visual builder for pages. Use it to customize your Home and landing pages.', 'bongoto-woocommerce' ), ), array( 'slug' => 'bongoto-pro', 'file' => 'bongoto-pro/bongoto-pro.php', 'label' => 'Bongoto Pro Addon', 'desc' => __( 'Unlocks premium headers, footers, templates and auto-updates for Bongoto WooCommerce.', 'bongoto-woocommerce' ), ), ); // Quick links. $links = array( array( __( 'Open Customizer', 'bongoto-woocommerce' ), admin_url( 'customize.php' ) ), array( __( 'Menus', 'bongoto-woocommerce' ), admin_url( 'nav-menus.php' ) ), array( __( 'Widgets', 'bongoto-woocommerce' ), admin_url( 'widgets.php' ) ), array( __( 'Reading Settings', 'bongoto-woocommerce' ), admin_url( 'options-reading.php' ) ), ); ?>