Пример #1
0
 /**
  * Save settings via ajax
  *
  * @return void
  */
 function ajax_settings()
 {
     if (!dokan_is_user_seller(get_current_user_id())) {
         wp_send_json_error(__('Are you cheating?', 'dokan'));
     }
     $_POST['dokan_update_profile'] = '';
     switch ($_POST['form_id']) {
         case 'profile-form':
             if (!wp_verify_nonce($_POST['_wpnonce'], 'dokan_profile_settings_nonce')) {
                 wp_send_json_error(__('Are you cheating?', 'dokan'));
             }
             $ajax_validate = $this->profile_validate();
             break;
         case 'store-form':
             if (!wp_verify_nonce($_POST['_wpnonce'], 'dokan_store_settings_nonce')) {
                 wp_send_json_error(__('Are you cheating?', 'dokan'));
             }
             $ajax_validate = $this->store_validate();
             break;
         case 'payment-form':
             if (!wp_verify_nonce($_POST['_wpnonce'], 'dokan_payment_settings_nonce')) {
                 wp_send_json_error(__('Are you cheating?', 'dokan'));
             }
             $ajax_validate = $this->payment_validate();
             break;
     }
     if (is_wp_error($ajax_validate)) {
         wp_send_json_error($ajax_validate->errors);
     }
     // we are good to go
     $save_data = $this->insert_settings_info();
     $progress_bar = dokan_get_profile_progressbar();
     $success_msg = __('Your information has been saved successfully', 'dokan');
     $data = array('progress' => $progress_bar, 'msg' => $success_msg);
     wp_send_json_success($data);
 }
Пример #2
0
<div class="dokan-dashboard-wrap">
    <?php 
dokan_get_template('dashboard-nav.php', array('active_menu' => 'dashboard'));
?>

    <div class="dokan-dashboard-content">

        <?php 
if (!dokan_is_seller_enabled($user_id)) {
    dokan_seller_not_enabled_notice();
}
?>

        <article class="dashboard-content-area">
            <?php 
echo dokan_get_profile_progressbar();
?>
            <div class="dokan-w6 dokan-dash-left">
                <div class="dashboard-widget big-counter">
                    <ul class="list-inline">
                        <li>
                            <div class="title"><?php 
_e('Pageview', 'dokan');
?>
</div>
                            <div class="count"><?php 
echo dokan_number_format($pageviews);
?>
</div>
                        </li>
                        <li>
Пример #3
0
 /**
  * Add progressbar in settings save feedback message
  *
  * @since 2.4
  *
  * @param array $message
  *
  * @return array
  */
 public function add_progressbar_in_settings_save_response($message)
 {
     $progress_bar = dokan_get_profile_progressbar();
     $message['progress'] = $progress_bar;
     return $message;
 }
Пример #4
0
    /**
     * Show the settings form
     *
     * @param  string
     *
     * @return void
     */
    function setting_field($validate = '')
    {
        global $current_user;
        if (isset($_GET['message'])) {
            ?>
            <div class="dokan-alert dokan-alert-success">
                <button type="button" class="dokan-close" data-dismiss="alert">&times;</button>
                <strong><?php 
            _e('Your profile has been updated successfully!', 'dokan');
            ?>
</strong>
            </div>
            <?php 
        }
        $profile_info = dokan_get_store_info($current_user->ID);
        $banner = isset($profile_info['banner']) ? absint($profile_info['banner']) : 0;
        $storename = isset($profile_info['store_name']) ? esc_attr($profile_info['store_name']) : '';
        $gravatar = isset($profile_info['gravatar']) ? absint($profile_info['gravatar']) : 0;
        $fb = isset($profile_info['social']['fb']) ? esc_url($profile_info['social']['fb']) : '';
        $twitter = isset($profile_info['social']['twitter']) ? esc_url($profile_info['social']['twitter']) : '';
        $gplus = isset($profile_info['social']['gplus']) ? esc_url($profile_info['social']['gplus']) : '';
        $linkedin = isset($profile_info['social']['linkedin']) ? esc_url($profile_info['social']['linkedin']) : '';
        $youtube = isset($profile_info['social']['youtube']) ? esc_url($profile_info['social']['youtube']) : '';
        $flickr = isset($profile_info['social']['flickr']) ? esc_url($profile_info['social']['flickr']) : '';
        $instagram = isset($profile_info['social']['instagram']) ? esc_url($profile_info['social']['instagram']) : '';
        // bank
        $phone = isset($profile_info['phone']) ? esc_attr($profile_info['phone']) : '';
        $show_email = isset($profile_info['show_email']) ? esc_attr($profile_info['show_email']) : 'no';
        $address = isset($profile_info['address']) ? esc_textarea($profile_info['address']) : '';
        $map_location = isset($profile_info['location']) ? esc_attr($profile_info['location']) : '';
        $map_address = isset($profile_info['find_address']) ? esc_attr($profile_info['find_address']) : '';
        $dokan_category = isset($profile_info['dokan_category']) ? $profile_info['dokan_category'] : '';
        if (is_wp_error($validate)) {
            $social = $_POST['settings']['social'];
            $storename = $_POST['dokan_store_name'];
            $fb = esc_url($social['fb']);
            $twitter = esc_url($social['twitter']);
            $gplus = esc_url($social['gplus']);
            $linkedin = esc_url($social['linkedin']);
            $youtube = esc_url($social['youtube']);
            $phone = $_POST['setting_phone'];
            $address = $_POST['setting_address'];
            $map_location = $_POST['location'];
            $map_address = $_POST['find_address'];
        }
        ?>

            <div class="dokan-ajax-response">
                <?php 
        echo dokan_get_profile_progressbar();
        ?>
            </div>

            <?php 
        do_action('dokan_settings_before_form', $current_user, $profile_info);
        ?>

            <form method="post" id="settings-form"  action="" class="dokan-form-horizontal">

                <?php 
        wp_nonce_field('dokan_settings_nonce');
        ?>

                <div class="dokan-banner">

                    <div class="image-wrap<?php 
        echo $banner ? '' : ' dokan-hide';
        ?>
">
                        <?php 
        $banner_url = $banner ? wp_get_attachment_url($banner) : '';
        ?>
                        <input type="hidden" class="dokan-file-field" value="<?php 
        echo $banner;
        ?>
" name="dokan_banner">
                        <img class="dokan-banner-img" src="<?php 
        echo esc_url($banner_url);
        ?>
">

                        <a class="close dokan-remove-banner-image">&times;</a>
                    </div>

                    <div class="button-area<?php 
        echo $banner ? ' dokan-hide' : '';
        ?>
">
                        <i class="fa fa-cloud-upload"></i>

                        <a href="#" class="dokan-banner-drag dokan-btn dokan-btn-info dokan-theme"><?php 
        _e('Upload banner', 'dokan');
        ?>
</a>
                        <p class="help-block"><?php 
        _e('(Upload a banner for your store. Banner size is (825x300) pixel. )', 'dokan');
        ?>
</p>
                    </div>
                </div> <!-- .dokan-banner -->

                <?php 
        do_action('dokan_settings_after_banner', $current_user, $profile_info);
        ?>

                <div class="dokan-form-group">
                    <label class="dokan-w3 dokan-control-label" for="dokan_store_name"><?php 
        _e('Store Name', 'dokan');
        ?>
</label>

                    <div class="dokan-w5 dokan-text-left">
                        <input id="dokan_store_name" required value="<?php 
        echo $storename;
        ?>
" name="dokan_store_name" placeholder="store name" class="dokan-form-control" type="text">
                    </div>
                </div>

                <div class="dokan-form-group">
                    <label class="dokan-w3 dokan-control-label" for="dokan_gravatar"><?php 
        _e('Profile Picture', 'dokan');
        ?>
</label>

                    <div class="dokan-w5 dokan-gravatar">
                        <div class="dokan-left gravatar-wrap<?php 
        echo $gravatar ? '' : ' dokan-hide';
        ?>
">
                            <?php 
        $gravatar_url = $gravatar ? wp_get_attachment_url($gravatar) : '';
        ?>
                            <input type="hidden" class="dokan-file-field" value="<?php 
        echo $gravatar;
        ?>
" name="dokan_gravatar">
                            <img class="dokan-gravatar-img" src="<?php 
        echo esc_url($gravatar_url);
        ?>
">
                            <a class="dokan-close dokan-remove-gravatar-image">&times;</a>
                        </div>
                        <div class="gravatar-button-area<?php 
        echo $gravatar ? ' dokan-hide' : '';
        ?>
">
                            <a href="#" class="dokan-gravatar-drag dokan-btn dokan-btn-default"><i class="fa fa-cloud-upload"></i> <?php 
        _e('Upload Photo', 'dokan');
        ?>
</a>
                        </div>
                    </div>
                </div>

                <div class="dokan-form-group">
                    <label class="dokan-w3 dokan-control-label" for="settings[social][fb]"><?php 
        _e('Social Profile', 'dokan');
        ?>
</label>

                    <div class="dokan-w5 dokan-text-left">
                        <div class="dokan-input-group dokan-form-group">
                            <span class="dokan-input-group-addon"><i class="fa fa-facebook-square"></i></span>
                            <input id="settings[social][fb]" value="<?php 
        echo $fb;
        ?>
" name="settings[social][fb]" class="dokan-form-control" placeholder="http://" type="text">
                        </div>
                        <div class="dokan-input-group dokan-form-group">
                            <span class="dokan-input-group-addon"><i class="fa fa-google-plus"></i></span>
                            <input id="settings[social][gplus]" value="<?php 
        echo $gplus;
        ?>
" name="settings[social][gplus]" class="dokan-form-control" placeholder="http://" type="text">
                        </div>
                        <div class="dokan-input-group dokan-form-group">
                            <span class="dokan-input-group-addon"><i class="fa fa-twitter"></i></span>
                            <input id="settings[social][twitter]" value="<?php 
        echo $twitter;
        ?>
" name="settings[social][twitter]" class="dokan-form-control" placeholder="http://" type="text">
                        </div>

                        <div class="dokan-input-group dokan-form-group">
                            <span class="dokan-input-group-addon"><i class="fa fa-linkedin"></i></span>
                            <input id="settings[social][linkedin]" value="<?php 
        echo $linkedin;
        ?>
" name="settings[social][linkedin]" class="dokan-form-control" placeholder="http://" type="text">
                        </div>

                        <div class="dokan-input-group dokan-form-group">
                            <span class="dokan-input-group-addon"><i class="fa fa-youtube"></i></span>
                            <input id="settings[social][youtube]" value="<?php 
        echo $youtube;
        ?>
" name="settings[social][youtube]" class="dokan-form-control" placeholder="http://" type="text">
                        </div>

                        <div class="dokan-input-group dokan-form-group">
                            <span class="dokan-input-group-addon"><i class="fa fa-instagram"></i></span>
                            <input id="settings[social][instagram]" value="<?php 
        echo $instagram;
        ?>
" name="settings[social][instagram]" class="dokan-form-control" placeholder="http://" type="text">
                        </div>

                        <div class="dokan-input-group dokan-form-group">
                            <span class="dokan-input-group-addon"><i class="fa fa-flickr"></i></span>
                            <input id="settings[social][flickr]" value="<?php 
        echo $flickr;
        ?>
" name="settings[social][flickr]" class="dokan-form-control" placeholder="http://" type="text">
                        </div>

                    </div>
                </div>

                <!-- payment tab -->
                <div class="dokan-form-group">
                    <label class="dokan-w3 dokan-control-label" for="dokan_setting"><?php 
        _e('Payment Method', 'dokan');
        ?>
</label>
                    <div class="dokan-w6">

                        <?php 
        $methods = dokan_withdraw_get_active_methods();
        ?>
                        <div id="payment_method_tab">
                            <ul class="dokan_tabs" style="margin-bottom: 10px; margin-left:0px;">
                                <?php 
        $count = 0;
        foreach ($methods as $method_key) {
            $method = dokan_withdraw_get_method($method_key);
            ?>
                                    <li<?php 
            echo $count == 0 ? ' class="active"' : '';
            ?>
><a href="#dokan-payment-<?php 
            echo $method_key;
            ?>
" data-toggle="tab"><?php 
            echo $method['title'];
            ?>
</a></li>
                                    <?php 
            $count++;
        }
        ?>
                            </ul>

                            <!-- Tab panes -->
                            <div class="tabs_container">

                                <?php 
        $count = 0;
        foreach ($methods as $method_key) {
            $method = dokan_withdraw_get_method($method_key);
            ?>
                                    <div class="tab-pane<?php 
            echo $count == 0 ? ' active' : '';
            ?>
" id="dokan-payment-<?php 
            echo $method_key;
            ?>
">
                                        <?php 
            if (is_callable($method['callback'])) {
                call_user_func($method['callback'], $profile_info);
            }
            ?>
                                    </div>
                                    <?php 
            $count++;
        }
        ?>
                            </div> <!-- .tabs_container -->
                        </div> <!-- .payment method tab -->
                    </div> <!-- .dokan-w4 -->
                </div> <!-- .dokan-form-group -->

                <div class="dokan-form-group">
                    <label class="dokan-w3 dokan-control-label" for="setting_phone"><?php 
        _e('Phone No', 'dokan');
        ?>
</label>
                    <div class="dokan-w5 dokan-text-left">
                        <input id="setting_phone" value="<?php 
        echo $phone;
        ?>
" name="setting_phone" placeholder="+123456.." class="dokan-form-control input-md" type="text">
                    </div>
                </div>

                <div class="dokan-form-group">
                    <label class="dokan-w3 dokan-control-label" for="setting_phone"><?php 
        _e('Email', 'dokan');
        ?>
</label>
                    <div class="dokan-w5 dokan-text-left">
                        <div class="checkbox">
                            <label>
                                <input type="hidden" name="setting_show_email" value="no">
                                <input type="checkbox" name="setting_show_email" value="yes"<?php 
        checked($show_email, 'yes');
        ?>
> <?php 
        _e('Show email address in store', 'dokan');
        ?>
                            </label>
                        </div>
                    </div>
                </div>

                <div class="dokan-form-group">
                    <label class="dokan-w3 dokan-control-label" for="setting_address"><?php 
        _e('Address', 'dokan');
        ?>
</label>
                    <div class="dokan-w5 dokan-text-left">
                        <textarea class="dokan-form-control" rows="4" id="setting_address" name="setting_address"><?php 
        echo $address;
        ?>
</textarea>
                    </div>
                </div>

                <div class="dokan-form-group">
                    <label class="dokan-w3 dokan-control-label" for="setting_map"><?php 
        _e('Map', 'dokan');
        ?>
</label>

                    <div class="dokan-w4 dokan-text-left">
                        <input id="dokan-map-lat" type="hidden" name="location" value="<?php 
        echo $map_location;
        ?>
" size="30" />

                        <div class="dokan-input-group">
                            <span class="">
                                <input id="dokan-map-add" type="text" class="dokan-form-control" value="<?php 
        echo $map_address;
        ?>
" name="find_address" placeholder="<?php 
        _e('Type an address to find', 'dokan');
        ?>
" size="30" />
                                <a href="#" class="" id="dokan-location-find-btn" type="button"><?php 
        _e('Find Address', 'dokan');
        ?>
</a>
                            </span>
                        </div><!-- /input-group -->

                        <div class="dokan-google-map" id="dokan-map" style="width:400px; height:300px;"></div>
                    </div> <!-- col.md-4 -->
                </div> <!-- .dokan-form-group -->

                <?php 
        do_action('dokan_settings_form_bottom', $current_user, $profile_info);
        ?>

                <div class="dokan-form-group">

                    <div class="dokan-w4 ajax_prev dokan-text-left" style="margin-left:24%;">
                        <input type="submit" name="dokan_update_profile" class="dokan-btn dokan-btn-danger dokan-btn-theme" value="<?php 
        esc_attr_e('Update Settings', 'dokan');
        ?>
">
                    </div>
                </div>

            </form>

            <?php 
        do_action('dokan_settings_after_form', $current_user, $profile_info);
        ?>

                <script type="text/javascript">

                    (function($) {
                        $(function() {
                            <?php 
        $locations = explode(',', $map_location);
        $def_lat = isset($locations[0]) ? $locations[0] : 90.40714300000002;
        $def_long = isset($locations[1]) ? $locations[1] : 23.709921;
        ?>
                            var def_zoomval = 12;
                            var def_longval = '<?php 
        echo $def_long;
        ?>
';
                            var def_latval = '<?php 
        echo $def_lat;
        ?>
';
                            var curpoint = new google.maps.LatLng(def_latval, def_longval),
                                geocoder   = new window.google.maps.Geocoder(),
                                $map_area = $('#dokan-map'),
                                $input_area = $( '#dokan-map-lat' ),
                                $input_add = $( '#dokan-map-add' ),
                                $find_btn = $( '#dokan-location-find-btn' );

                            autoCompleteAddress();

                            $find_btn.on('click', function(e) {
                                e.preventDefault();

                                geocodeAddress( $input_add.val() );
                            });

                            var gmap = new google.maps.Map( $map_area[0], {
                                center: curpoint,
                                zoom: def_zoomval,
                                mapTypeId: window.google.maps.MapTypeId.ROADMAP
                            });

                            var marker = new window.google.maps.Marker({
                                position: curpoint,
                                map: gmap,
                                draggable: true
                            });

                            window.google.maps.event.addListener( gmap, 'click', function ( event ) {
                                marker.setPosition( event.latLng );
                                updatePositionInput( event.latLng );
                            } );

                            window.google.maps.event.addListener( marker, 'drag', function ( event ) {
                                updatePositionInput(event.latLng );
                            } );

                            function updatePositionInput( latLng ) {
                                $input_area.val( latLng.lat() + ',' + latLng.lng() );
                            }

                            function updatePositionMarker() {
                                var coord = $input_area.val(),
                                    pos, zoom;

                                if ( coord ) {
                                    pos = coord.split( ',' );
                                    marker.setPosition( new window.google.maps.LatLng( pos[0], pos[1] ) );

                                    zoom = pos.length > 2 ? parseInt( pos[2], 10 ) : 12;

                                    gmap.setCenter( marker.position );
                                    gmap.setZoom( zoom );
                                }
                            }

                            function geocodeAddress( address ) {
                                geocoder.geocode( {'address': address}, function ( results, status ) {
                                    if ( status == window.google.maps.GeocoderStatus.OK ) {
                                        updatePositionInput( results[0].geometry.location );
                                        marker.setPosition( results[0].geometry.location );
                                        gmap.setCenter( marker.position );
                                        gmap.setZoom( 15 );
                                    }
                                } );
                            }

                            function autoCompleteAddress(){
                                if (!$input_add) return null;

                                $input_add.autocomplete({
                                    source: function(request, response) {
                                        // TODO: add 'region' option, to help bias geocoder.
                                        geocoder.geocode( {'address': request.term }, function(results, status) {
                                            response(jQuery.map(results, function(item) {
                                                return {
                                                    label     : item.formatted_address,
                                                    value     : item.formatted_address,
                                                    latitude  : item.geometry.location.lat(),
                                                    longitude : item.geometry.location.lng()
                                                };
                                            }));
                                        });
                                    },
                                    select: function(event, ui) {

                                        $input_area.val(ui.item.latitude + ',' + ui.item.longitude );

                                        var location = new window.google.maps.LatLng(ui.item.latitude, ui.item.longitude);

                                        gmap.setCenter(location);
                                        // Drop the Marker
                                        setTimeout( function(){
                                            marker.setValues({
                                                position    : location,
                                                animation   : window.google.maps.Animation.DROP
                                            });
                                        }, 1500);
                                    }
                                });
                            }

                        });
                    })(jQuery);
                </script>

                <script>
                    (function($){
                        $(document).ready(function(){
                            $('#payment_method_tab').easytabs();
                        });
                    })(jQuery)
                </script>

                <script type="text/javascript">

                    jQuery(function($){
                        // $('#setting_category').chosen({
                        //     width: "95%"
                        // }).change(function() {
                        //     $("form#settings-form").validate().element("#setting_category");
                        // });
                    })

                </script>

        <?php 
    }
Пример #5
0
 /**
  * Show Profile progressbar
  *
  * @return void
  */
 public function show_profile_progressbar()
 {
     echo dokan_get_profile_progressbar();
 }