'; echo '

' . esc_html__( 'Bongoto Marketplace — Quick Setup', 'bongoto-marketplace' ) . '

'; echo '

' . esc_html__( 'Install/activate recommended plugins or import a demo.', 'bongoto-marketplace' ) . '

'; echo '

' . esc_html__( 'Open Setup', 'bongoto-marketplace' ) . ' '; echo '' . esc_html__( 'Dismiss', 'bongoto-marketplace' ) . '

'; echo ''; } ); add_action( 'admin_init', function () { if ( isset( $_GET['bongoto-marketplace-dismiss'] ) && check_admin_referer( 'bongoto_marketplace_dismiss' ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended delete_transient( 'bongoto_marketplace_show_setup' ); } } ); /* ------------------------------------------------------------------------- * 4) Helpers * ------------------------------------------------------------------------- */ /** Pro check (filter-aware) */ if ( ! function_exists( 'bongoto_is_pro_active' ) ) { function bongoto_is_pro_active() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; $active = function_exists( 'is_plugin_active' ) && is_plugin_active( 'bongoto-pro/bongoto-pro.php' ); /** Allow overriding from Pro. */ return (bool) apply_filters( 'bongoto/is_pro_active', $active ); } } /** Shorthand plugin checks */ function bongoto_marketplace_is_elementor() { return class_exists( '\Elementor\Plugin' ); } function bongoto_marketplace_is_woo() { return function_exists( 'WC' ); } function bongoto_marketplace_is_dokan() { return defined( 'DOKAN_PLUGIN_VERSION' ); } /* ------------------------------------------------------------------------- * 5) Feature Locks (Footer credit, Seller upload button, Header variants) * ------------------------------------------------------------------------- */ /** Footer copyright lock */ add_filter( 'bongoto_marketplace_footer_credit', function ( $credit ) { if ( ! bongoto_is_pro_active() ) { $credit = sprintf( /* translators: %s: site name */ esc_html__( '© %s — Powered by Bongoto Marketplace', 'bongoto-marketplace' ), get_bloginfo( 'name' ) ); } return $credit; } ); /** Seller upload button (call from template) */ function bongoto_marketplace_render_seller_upload_button() { if ( ! bongoto_is_pro_active() ) { return; } if ( ! bongoto_marketplace_is_woo() || ! bongoto_marketplace_is_dokan() ) { return; } echo '' . esc_html__( 'Upload Product', 'bongoto-marketplace' ) . ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } /** Header variant whitelist for Customizer/UI */ add_filter( 'bongoto/header/allowed_variants', function ( $allowed ) { return bongoto_is_pro_active() ? array( 1, 2, 3, 4, 5 ) : array( 1 ); } ); /* ------------------------------------------------------------------------- * 6) Utility: version for static files * ------------------------------------------------------------------------- */ if ( ! function_exists( 'bongoto_file_version' ) ) { function bongoto_file_version( $relative_path ) { $path = BONGOTO_DIR . ltrim( $relative_path, '/' ); return file_exists( $path ) ? (string) filemtime( $path ) : BONGOTO_VERSION; } } /* ------------------------------------------------------------------------- * 7) Full theme setup * ------------------------------------------------------------------------- */ if ( ! function_exists( 'bongoto_setup' ) ) { function bongoto_setup() { load_theme_textdomain( 'bongoto-marketplace', BONGOTO_DIR . 'languages' ); add_theme_support( 'title-tag' ); add_theme_support( 'post-thumbnails' ); add_image_size( 'bongoto-thumb', 540, 360, true ); add_image_size( 'bongoto-card', 720, 480, true ); add_theme_support( 'custom-logo', array( 'height' => 80, 'width' => 240, 'flex-height' => true, 'flex-width' => true, ) ); add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', 'script', 'style', 'navigation-widgets', ) ); add_theme_support( 'wp-block-styles' ); add_theme_support( 'editor-styles' ); add_editor_style( 'assets/css/main.css' ); add_theme_support( 'align-wide' ); add_theme_support( 'responsive-embeds' ); add_theme_support( 'woocommerce' ); add_theme_support( 'automatic-feed-links' ); add_theme_support( 'custom-background' ); add_theme_support( 'custom-header' ); register_nav_menus( array( 'primary' => __( 'Primary Menu', 'bongoto-marketplace' ), 'footer' => __( 'Footer Menu', 'bongoto-marketplace' ), 'topbar' => __( 'Top Bar Menu', 'bongoto-marketplace' ), ) ); } } add_action( 'after_setup_theme', 'bongoto_setup' ); /* Content width */ if ( ! isset( $content_width ) ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound $content_width = 720; } /* ------------------------------------------------------------------------- * 8) Widgets * ------------------------------------------------------------------------- */ function bongoto_widgets_init() { for ( $i = 1; $i <= 4; $i++ ) { register_sidebar( array( /* translators: %d: footer column number */ 'name' => sprintf( __( 'Footer Column %d', 'bongoto-marketplace' ), $i ), 'id' => "footer-$i", 'description' => __( 'Add widgets here to appear in the footer.', 'bongoto-marketplace' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); } register_sidebar( array( 'name' => __( 'Sidebar', 'bongoto-marketplace' ), 'id' => 'sidebar-1', 'description' => __( 'Add widgets here for posts/pages if needed.', 'bongoto-marketplace' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => __( 'Shop Sidebar', 'bongoto-marketplace' ), 'id' => 'shop-sidebar', 'description' => __( 'Widgets shown on the WooCommerce shop and product archive pages.', 'bongoto-marketplace' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); } add_action( 'widgets_init', 'bongoto_widgets_init' ); /* ------------------------------------------------------------------------- * 9) Body Classes * ------------------------------------------------------------------------- */ function bongoto_body_class( $classes ) { $classes[] = bongoto_is_pro_active() ? 'bongoto-pro-active' : 'bongoto-free'; if ( class_exists( 'WooCommerce' ) ) { $classes[] = 'has-woocommerce'; } if ( class_exists( 'WeDevs_Dokan' ) ) { $classes[] = 'has-dokan'; } return $classes; } add_filter( 'body_class', 'bongoto_body_class' ); /* ------------------------------------------------------------------------- * 10) Includes * ------------------------------------------------------------------------- */ $includes = array( 'inc/setup.php', 'inc/assets.php', 'inc/template-functions.php', 'inc/hooks.php', 'inc/security.php', 'inc/demo-setup.php', 'inc/admin/welcome.php', 'inc/customizer/customizer.php', 'inc/customizer/sanitize.php', 'inc/customizer/options-general.php', 'inc/customizer/options-header.php', 'inc/customizer/options-footer.php', 'inc/customizer/controls/class-sortable-control.php', 'inc/class-bongoto-header-manager.php', 'inc/class-bongoto-footer-manager.php', 'inc/compatibility/elementor.php', 'inc/compatibility/woocommerce.php', 'inc/compatibility/dokan.php', ); foreach ( $includes as $rel ) { $path = BONGOTO_DIR . ltrim( $rel, '/' ); if ( file_exists( $path ) ) { require_once $path; } } /* ------------------------------------------------------------------------- * 11) Search Form Fallback Helper * ------------------------------------------------------------------------- */ function bongoto_get_search_form( $echo = true ) { ob_start(); get_template_part( 'searchform' ); $form = ob_get_clean(); if ( $echo ) { // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo $form; return null; } return $form; } /* ------------------------------------------------------------------------- * 12) Simple Ajax placeholder * ------------------------------------------------------------------------- */ function bongoto_ajax_placeholder() { wp_send_json_success( array( 'message' => __( 'OK', 'bongoto-marketplace' ) ) ); } add_action( 'wp_ajax_bongoto_ping', 'bongoto_ajax_placeholder' ); add_action( 'wp_ajax_nopriv_bongoto_ping', 'bongoto_ajax_placeholder' ); /* ------------------------------------------------------------------------- * 13) WooCommerce tweaks * ------------------------------------------------------------------------- */ add_filter( 'loop_shop_columns', function () { return 4; } ); add_filter( 'loop_shop_per_page', function ( $cols ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable return 16; }, 20 ); /** Default shop order: latest */ add_filter( 'woocommerce_default_catalog_orderby', function () { return 'date'; } ); /** Force site search to products only (frontend) */ add_action( 'pre_get_posts', function ( $query ) { if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) { $query->set( 'post_type', 'product' ); } } ); /** Purchasable logic: admins/vendors/sellers always; free price true */ add_filter( 'woocommerce_is_purchasable', function ( $purchasable, $product ) { if ( is_user_logged_in() ) { $user = wp_get_current_user(); $roles = (array) $user->roles; if ( in_array( 'administrator', $roles, true ) || in_array( 'vendor', $roles, true ) || in_array( 'seller', $roles, true ) ) { return true; } } if ( (float) $product->get_price() === 0.0 ) { return true; } return $purchasable; }, 999, 2 ); /** Replace "Read more" with "Free Download" for free products on loops */ add_filter( 'woocommerce_loop_add_to_cart_link', function ( $button, $product ) { if ( (float) $product->get_price() === 0.0 ) { $url = get_permalink( $product->get_id() ); $button = '' . esc_html__( 'Free Download', 'bongoto-marketplace' ) . ''; } return $button; }, 999, 2 ); /* ------------------------------------------------------------------------- * 14) Header CTA URL override (guest → become vendor) * ------------------------------------------------------------------------- */ add_filter( 'bongoto/header_cta', function ( $out ) { $is_seller = is_user_logged_in() && ( ( function_exists( 'dokan_is_user_seller' ) && dokan_is_user_seller( get_current_user_id() ) ) || current_user_can( 'manage_options' ) ); if ( ! $is_seller ) { $my_account = function_exists( 'wc_get_page_permalink' ) ? wc_get_page_permalink( 'myaccount' ) : home_url( '/my-account/' ); $out['label'] = __( 'Start Selling', 'bongoto-marketplace' ); $out['url'] = add_query_arg( 'become_vendor', '1', $my_account ); } return $out; }, 999 ); /** Legacy route redirect */ add_action( 'template_redirect', function () { $req_path = trim( (string) parse_url( $_SERVER['REQUEST_URI'] ?? '', PHP_URL_PATH ), '/' ); if ( 'my-account/bongoto-become-vendor' === $req_path ) { $my_account = function_exists( 'wc_get_page_permalink' ) ? wc_get_page_permalink( 'myaccount' ) : home_url( '/my-account/' ); wp_safe_redirect( add_query_arg( 'become_vendor', '1', $my_account ), 301 ); exit; } } ); /* ------------------------------------------------------------------------- * 15) Elementor Home auto-import (JSON under assets/elementor/) * ------------------------------------------------------------------------- */ /** Return default demo JSON absolute path if present */ function bongoto_home_json_path() { $file = BONGOTO_DIR . 'assets/elementor/digital-marketplace-01.json'; return file_exists( $file ) ? $file : ''; } /** Normalize Elementor JSON (make /assets/... absolute; fallback for search widget) */ function bongoto_normalize_elementor_json( $json ) { $data = json_decode( $json, true ); if ( JSON_ERROR_NONE !== json_last_error() || ! is_array( $data ) ) { return $json; } $theme_uri = BONGOTO_URI; $walk = static function ( &$node ) use ( &$walk, $theme_uri ) { // Image url. if ( isset( $node['settings']['image']['url'] ) && is_string( $node['settings']['image']['url'] ) ) { $u = $node['settings']['image']['url']; if ( 0 === strpos( $u, '/assets/' ) ) { $node['settings']['image']['url'] = $theme_uri . ltrim( $u, '/' ); } } // Slides images. if ( isset( $node['settings']['slides'] ) && is_array( $node['settings']['slides'] ) ) { foreach ( $node['settings']['slides'] as &$slide ) { if ( isset( $slide['image']['url'] ) && is_string( $slide['image']['url'] ) ) { $u = $slide['image']['url']; if ( 0 === strpos( $u, '/assets/' ) ) { $slide['image']['url'] = $theme_uri . ltrim( $u, '/' ); } } } unset( $slide ); } // Elementor Pro search-form → shortcode fallback. if ( isset( $node['widgetType'] ) && 'search-form' === $node['widgetType'] && ! class_exists( '\ElementorPro\Plugin' ) ) { $node['widgetType'] = 'shortcode'; $node['settings'] = array( 'shortcode' => function_exists( 'WC' ) ? '[woocommerce_product_search]' : '[bongoto_search]', 'align' => $node['settings']['align'] ?? 'center', ); } // Recurse. if ( isset( $node['elements'] ) && is_array( $node['elements'] ) ) { foreach ( $node['elements'] as &$child ) { $walk( $child ); } unset( $child ); } }; foreach ( $data as &$root ) { $walk( $root ); } unset( $root ); return wp_json_encode( $data ); } /** Import JSON into a “Home” page and set as Front Page */ function bongoto_import_home_from_json() { $path = bongoto_home_json_path(); if ( ! $path ) { return new WP_Error( 'missing_json', __( 'Home JSON file not found.', 'bongoto-marketplace' ) ); } $json = file_get_contents( $path ); if ( '' === trim( (string) $json ) ) { return new WP_Error( 'empty_json', __( 'Home JSON file is empty.', 'bongoto-marketplace' ) ); } $json = bongoto_normalize_elementor_json( $json ); $page = get_page_by_title( 'Home' ); $page_id = ( $page && $page->ID ) ? (int) $page->ID : 0; if ( ! $page_id ) { $page_id = wp_insert_post( array( 'post_title' => 'Home', 'post_type' => 'page', 'post_status' => 'publish', ) ); if ( is_wp_error( $page_id ) ) { return $page_id; } } if ( bongoto_marketplace_is_elementor() ) { update_post_meta( $page_id, '_elementor_edit_mode', 'builder' ); update_post_meta( $page_id, '_elementor_template_type', 'wp-page' ); update_post_meta( $page_id, '_elementor_data', wp_slash( $json ) ); wp_update_post( array( 'ID' => $page_id, 'post_content' => '', ) ); } else { $placeholder = '
' . esc_html__( 'Please install/activate Elementor to render the Bongoto Home layout.', 'bongoto-marketplace' ) . '
'; wp_update_post( array( 'ID' => $page_id, 'post_content' => $placeholder, ) ); } update_option( 'show_on_front', 'page' ); update_option( 'page_on_front', $page_id ); // Optional lock meta for free users. if ( ! bongoto_is_pro_active() ) { update_post_meta( $page_id, '_bongoto_locked', '1' ); } else { delete_post_meta( $page_id, '_bongoto_locked' ); } return $page_id; } /** On first activation only (if no front page is set) */ add_action( 'after_switch_theme', function () { if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) ) { return; } bongoto_import_home_from_json(); } ); /* ------------------------------------------------------------------------- * 16) Admin menu (Theme screen submenu; Theme-Review safe) * ------------------------------------------------------------------------- */ add_action( 'admin_menu', function () { if ( ! current_user_can( 'manage_options' ) ) { return; } add_theme_page( __( 'Bongoto Setup', 'bongoto-marketplace' ), __( 'Bongoto Setup', 'bongoto-marketplace' ), 'manage_options', 'bongoto-marketplace-setup', 'bongoto_marketplace_render_setup_page' // in inc/admin/setup-page.php ); } ); /* ------------------------------------------------------------------------- * 17) Comments helpers * ------------------------------------------------------------------------- */ add_action( 'wp_enqueue_scripts', function () { if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } ); if ( ! function_exists( 'bongoto_list_comments' ) ) { function bongoto_list_comments( $comment, $args, $depth ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found $GLOBALS['comment'] = $comment; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited ?>
  • id="li-comment-">