Last active
November 21, 2017 13:26
-
-
Save sabbir1991/9a305a4dd6c376e17a9bf7fa745992e7 to your computer and use it in GitHub Desktop.
Added extra widget in dokan store page with store extra information
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Booth news field seller settings */ | |
add_filter( 'dokan_settings_form_bottom', 'extra_fields', 10, 2); | |
function extra_fields( $current_user, $profile_info ){ | |
$booth_news= get_user_meta( $current_user, 'booth_news', true ); | |
$about_us= get_user_meta( $current_user, 'about_us', true ); | |
?> | |
<div class="gregcustom dokan-form-group"> | |
<label class="dokan-w3 dokan-control-label" for="setting_address"> | |
<?php _e( 'Booth news', 'dokan' ); ?> | |
</label> | |
<div class="dokan-w8 dokan-text-left"> | |
<?php | |
$booth_news_args = array( | |
'editor_height' => 200, | |
'media_buttons' => false, | |
'teeny' => true, | |
'quicktags' => false | |
); | |
wp_editor( $booth_news, 'booth_news', $booth_news_args ); | |
?> | |
</div> | |
<div class="gregcustom dokan-form-group"> | |
<label class="dokan-w3 dokan-control-label" for="setting_address"> | |
<?php _e( 'About Us', 'dokan' ); ?> | |
</label> | |
<div class="dokan-w8 dokan-text-left"> | |
<?php | |
$about_us_args = array( | |
'editor_height' => 200, | |
'media_buttons' => false, | |
'teeny' => true, | |
'quicktags' => false | |
); | |
wp_editor( $about_us, 'about_us', $about_us_args ); | |
?> | |
</div> | |
<?php | |
} | |
/* Saving the booth news field */ | |
add_action( 'dokan_store_profile_saved','save_extra_fields', 10 ); | |
function save_extra_fields( $store_id ) { | |
if ( ! $store_id ) { | |
return; | |
} | |
if ( ! isset( $_POST['booth_news'] ) && ! isset( $_POST['about_us'] ) ) { | |
return; | |
} | |
update_user_meta( $store_id, 'booth_news', $_POST['booth_news'] ); | |
update_user_meta( $store_id, 'about_us', $_POST['about_us'] ); | |
} | |
/*Showing extra field on the store page sidebar*/ | |
add_action( 'dokan_sidebar_store_after','custom_side_bar',10,2); | |
function custom_side_bar( $store_user, $store_info ){ | |
$booth_news = get_user_meta( $store_user->ID, 'booth_news', true ); | |
$about_us = get_user_meta( $store_user->ID, 'about_us', true ); | |
?> | |
<?php if ( !empty( $booth_news ) ) { ?> | |
<div class="dokan-store-sidebar"> | |
<aside class="widget"> | |
<h3 class="widget-title"><?php _e( 'Booth News', 'dokan' ); ?></h3> | |
<?php echo wpautop( $booth_news ); ?> | |
</aside> | |
</div> | |
<?php } ?> | |
<?php if ( !empty( $about_us ) ) { ?> | |
<div class="dokan-store-sidebar"> | |
<aside class="widget"> | |
<h3 class="widget-title"><?php _e( 'About Us', 'dokan' ); ?></h3> | |
<?php echo wpautop( $about_us ); ?> | |
</aside> | |
</div> | |
<?php } ?> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment