__( 'Upload', 'bongoto-marketplace' ), 'url' => bongoto_get_upload_url(), 'icon' => 'upload' )
: array( 'label' => __( 'Start Selling', 'bongoto-marketplace' ), 'url' => bongoto_get_start_selling_url(), 'icon' => 'upload' )
);
}
}
/* ---------------------------
* 3) Body Class
* --------------------------- */
if ( ! function_exists( 'bongoto_dokan_body_class' ) ) {
function bongoto_dokan_body_class( $classes ) {
if ( bongoto_is_dokan_active() ) {
$classes[] = 'has-dokan';
if ( bongoto_is_vendor_user() ) {
$classes[] = 'is-vendor';
}
}
return $classes;
}
}
add_filter( 'body_class', 'bongoto_dokan_body_class' );
/* --------------------------------------------------------------------
* 4) Shortcode (MOVED TO PLUGIN)
* --------------------------------------------------------------------
* ❌ থিম থেকে শর্টকোড সরানো হয়েছে
* ✅ নিচের কোডটি এখন bongoto-pro প্লাগিনে রাখবেন:
* includes/Pro_Features/shortcodes.php
* if ( ! function_exists( 'bongoto_sc_upload_button' ) ) {
* function bongoto_sc_upload_button( $atts = array() ) {
* $atts = shortcode_atts(
* array( 'label' => __( 'Start Selling', 'bongoto-marketplace' ), 'class' => 'button' ),
* $atts,
* 'bongoto_upload_button'
* );
* $cta = bongoto_get_header_cta();
* $label = $atts['label'] ? $atts['label'] : $cta['label'];
* $class = sanitize_html_class( $atts['class'] );
* return '' . esc_html( $label ) . '';
* }
* }
* add_shortcode( 'bongoto_upload_button', 'bongoto_sc_upload_button' );
*/
/* -------------------------------------------------------------
* 5) My Account Dashboard → “Become a Seller” button
* ------------------------------------------------------------- */
if ( ! function_exists( 'bongoto_account_become_seller_button' ) ) {
function bongoto_account_become_seller_button() {
if ( ! is_user_logged_in() || bongoto_is_vendor_user() ) {
return;
}
$target = '';
if ( bongoto_is_dokan_active() && function_exists( 'dokan_get_page_url' ) ) {
$maybe = dokan_get_page_url( 'registration', 'dokan' );
if ( ! $maybe ) {
$maybe = dokan_get_page_url( 'reg', 'dokan' );
}
if ( $maybe ) {
$target = $maybe;
}
}
if ( ! $target ) {
$target = bongoto_get_start_selling_url();
}
echo '
';
}
}
add_action( 'woocommerce_account_dashboard', 'bongoto_account_become_seller_button', 25 );
/* --------------------------------------------------------------------
* 6) Auto-upgrade handler: ?become_vendor=1 → seller redirect
* -------------------------------------------------------------------- */
if ( ! function_exists( 'bongoto_handle_become_vendor' ) ) {
function bongoto_handle_become_vendor() {
if ( empty( $_GET['become_vendor'] ) ) {
return;
}
if ( ! is_user_logged_in() ) {
return;
}
if ( bongoto_is_vendor_user() ) {
wp_safe_redirect( bongoto_dokan_dashboard_url() );
exit;
}
$user_id = get_current_user_id();
if ( bongoto_is_dokan_active() ) {
if ( function_exists( 'dokan_set_new_seller_role' ) ) {
dokan_set_new_seller_role( $user_id );
} else {
$user = new WP_User( $user_id );
$user->add_role( 'seller' );
}
update_user_meta( $user_id, 'dokan_enable_selling', 'yes' );
$profile = get_user_meta( $user_id, 'dokan_profile_settings', true );
if ( empty( $profile ) || ! is_array( $profile ) ) {
$display = wp_get_current_user()->display_name;
update_user_meta(
$user_id,
'dokan_profile_settings',
array(
'store_name' => $display ? ( $display . '\'s Store' ) : 'My Store',
)
);
}
wp_safe_redirect( bongoto_dokan_dashboard_url() );
exit;
}
wp_safe_redirect( bongoto_safe_account_url() );
exit;
}
}
add_action( 'template_redirect', 'bongoto_handle_become_vendor', 1 );
/* -------------------------------------------------------------
* 7) Login redirect: retain become_vendor param
* ------------------------------------------------------------- */
if ( ! function_exists( 'bongoto_login_redirect_vendor' ) ) {
function bongoto_login_redirect_vendor( $redirect, $user ) {
$want_vendor = false;
if ( isset( $_REQUEST['become_vendor'] ) && '1' === $_REQUEST['become_vendor'] ) {
$want_vendor = true;
} elseif ( ! empty( $_SERVER['HTTP_REFERER'] ) && false !== strpos( $_SERVER['HTTP_REFERER'], 'become_vendor=1' ) ) {
$want_vendor = true;
}
if ( $want_vendor ) {
return add_query_arg( 'become_vendor', '1', bongoto_safe_account_url() );
}
return $redirect;
}
}
add_filter( 'woocommerce_login_redirect', 'bongoto_login_redirect_vendor', 10, 2 );
/* ---------------------------
* 8) Optional Header Helpers
* --------------------------- */
if ( ! function_exists( 'bongoto_dokan_account_link' ) ) {
function bongoto_dokan_account_link() {
$url = bongoto_safe_account_url();
echo '';
if ( function_exists( 'bongoto_icon' ) ) {
bongoto_icon( 'account', array( 'width' => 20, 'height' => 20 ) );
}
echo '' . esc_html__( 'My Account', 'bongoto-marketplace' ) . '';
}
}
if ( ! function_exists( 'bongoto_dokan_store_link' ) ) {
function bongoto_dokan_store_link() {
if ( ! bongoto_is_vendor_user() ) {
return;
}
$url = bongoto_dokan_store_url();
echo '' . esc_html__( 'My Store', 'bongoto-marketplace' ) . '';
}
}