function vcita_add_calendar($atts) { $vcita_widget = (array) get_option(VCITA_WIDGET_KEY); extract(shortcode_atts(array('type' => 'scheduler', 'email' => '', 'first_name' => '', 'last_name' => '', 'uid' => $vcita_widget['uid'], 'id' => '', 'title' => '', 'width' => '500px', 'height' => '450px'), $atts)); // If user isn't available - try and create one. if (!empty($email)) { $vcita_widget['email'] = $email; $vcita_widget['first_name'] = $first_name; $vcita_widget['last_name'] = $last_name; $vcita_widget['uid'] = ''; $vcita_widget = generate_or_validate_user($vcita_widget); // Don't save the user as the widget user - just use it $id = $vcita_widget["uid"]; } else { if (empty($id)) { if (empty($uid)) { $id = vcita_get_uid(); } else { $id = $uid; } } } return vcita_create_embed_code($type, $id, $width, $height); }
/** * Check the current user is a demo user */ function vcita_is_demo_user() { return vcita_get_uid() == VCITA_WIDGET_DEMO_UID; }
/** * Create the vCita floatting widget Settings form content. * * This is based on Wordpress guidelines for creating a single widget. */ function vcita_widget_admin() { vcita_add_stylesheet(); ?> <script type="text/javascript"> jQuery(function ($) { $('.start-login') .on('click', function(){ var callbackURL = "<?php echo $url = get_admin_url('', '', 'admin') . 'admin.php?page=' . VCITA_WIDGET_UNIQUE_ID . '/vcita-callback.php'; ?> "; var email = ""; $('.vcita-email').each(function(){ var tempMail = $(this).val(); if (tempMail) email = tempMail; if (email == $(this).data('watermark')) { email = ""; } }); var new_location = "http://" + "<?php echo VCITA_LOGIN_PATH . '?callback='; ?> " + encodeURIComponent(callbackURL) + "&invite="+"<?php echo VCITA_WIDGET_INVITE_CODE; ?> "+"&lang="+"<?php echo get_locale(); ?> "+"&email=" + email; window.location = new_location; }); $('.switch-account') .on('click', function(){ var callbackURL = "<?php echo $url = get_admin_url('', '', 'admin') . 'admin.php?page=' . VCITA_WIDGET_UNIQUE_ID . '/vcita-callback.php'; ?> "; var new_location = "http://" + "<?php echo VCITA_LOGIN_PATH . '?callback='; ?> " + encodeURIComponent(callbackURL) + "&invite="+"<?php echo VCITA_WIDGET_INVITE_CODE; ?> "+"&lang="+"<?php echo get_locale(); ?> "+"&login=true"; window.location = new_location; }); $('.vcita-email') .on('keypress', function(e){ if (e.keyCode == 13) { $('.start-login').click(); } }); $('a.preview') .bind('click', function(e){ var link = $(e.currentTarget); var height = link.data().height ? link.data().height : 600; var width = link.data().width ? link.data().width : 600; var specs = 'directories=0, height=' + height + ', width=' + width + ', location=0, menubar=0, scrollbars=0, status=0, titlebar=0, toolbar=0'; window.open(link.attr('href'), '_blank', specs); e.preventDefault(); }); }); </script> <div id="vcita_config" dir="ltr"> <?php if (vcita_is_demo_user()) { ?> <h3>Contact requests will be sent to this email:</h3> <input class="vcita-email" type="text" value=""/> <a href="javascript:void(0)" class="gray-button-style account start-login"><span></span>OK</a> <?php } else { $vcita_widget = (array) get_option(VCITA_WIDGET_KEY); ?> <h3>Contact requests will be sent to this email:</h3> <label class="checked" for="user-email"></label> <input class="vcita-email" type="text" disabled="disabled" value="<?php echo $vcita_widget["email"]; ?> "/> <br><br> <a href="javascript:void(0)" class="gray-button-style account switch-account" ><span></span>Change Email</a> <br><br> <a class="gray-button-style edit" href="<?php echo $url = get_admin_url('', '', 'admin') . 'admin.php?page=' . VCITA_WIDGET_UNIQUE_ID . '/vcita-sidebar-edit.php'; ?> "><span></span>Edit</a> <br><br> <a class="gray-button-style preview" href="http://<?php echo VCITA_SERVER_BASE; ?> /contact_widget?v=<?php echo vcita_get_uid(); ?> &ver=2" data-width="200" data-height="500"><span></span>Preview</a> <?php } ?> </div> <?php }