add_action('wps_deals_cart_footer_total_button', 'wps_deals_cart_order_total_footer', 5); add_action('wps_deals_cart_footer_total_button', 'wps_deals_cart_place_order_button_footer', 10); /** * Social Login Buttons * * @see wps_deals_social_login_facebook() - 5 * @see wps_deals_social_login_twitter() - 10 * @see wps_deals_social_login_google() - 15 * @see wps_deals_social_login_linkedin() - 20 * @see wps_deals_social_login_yahoo() - 25 */ $priority = 5; if (isset($wps_deals_options['social_order']) && !empty($wps_deals_options['social_order'])) { $socialmedias = $wps_deals_options['social_order']; } else { $socialorders = wps_deals_social_networks(); $socialmedias = array_keys($socialorders); } foreach ($socialmedias as $social) { add_action('wps_deals_checkout_social_login', 'wps_deals_social_login_' . $social, $priority); $priority += 5; } /** * Social Login Buttons Shortcode * * @see wps_deals_social_login_shortcode() */ add_action('wps_deals_social_login_shortcode', 'wps_deals_social_login_shortcode', 10, 2); //add action to add localize script for individual post data add_action('wps_deals_localize_map_script', 'wps_deals_localize_map_script'); /* **************************************************************************
/** * Get Social Network Sorted List * as per saved in options * * Handles to return social networks sorted * array to list in page * * @package Social Deals Engine * @since 1.0.0 */ function wps_deals_get_sorted_social_network() { global $wps_deals_options; $socials = wps_deals_social_networks(); if (!isset($wps_deals_options['social_order']) || empty($wps_deals_options['social_order'])) { return $socials; } $sorted_socials = $wps_deals_options['social_order']; $return = array(); for ($i = 0; $i < count($socials); $i++) { $return[$sorted_socials[$i]] = $socials[$sorted_socials[$i]]; } return apply_filters('wps_deals_sorted_social_network', $return); }
/** * Load Login Page For Social * * Handles to load login page for social * when no email address found * * @package Social Deals Engine * @since 1.0.0 */ public function wps_deals_social_login_redirect() { global $wps_deals_options; $socialtype = isset($_GET['dealsnetwork']) ? $_GET['dealsnetwork'] : ''; //get all social networks $allsocialtypes = wps_deals_social_networks(); if (!is_user_logged_in() && isset($_GET['wps_deals_social_login']) && !empty($socialtype) && array_key_exists($socialtype, $allsocialtypes)) { //check if session is set and !empty then it will take get_permalink url $redirect_url = $this->session->get('wps_deals_stcd_redirect_url'); $redirect_url = !empty($redirect_url) ? $redirect_url : wps_deals_get_current_page_url(); //get cart details $cartdetails = $this->cart->get(); $data = array(); //wordpress error class $errors = new WP_Error(); switch ($socialtype) { case 'twitter': //get twitter user data $tw_userdata = $this->twitter->wps_deals_social_get_twitter_user_data(); //check user id is set or not for twitter if (!empty($tw_userdata) && isset($tw_userdata->id) && !empty($tw_userdata->id)) { $data['first_name'] = $tw_userdata->name; $data['last_name'] = ''; $data['name'] = $tw_userdata->screen_name; //display name of user $data['type'] = 'twitter'; $data['all'] = $tw_userdata; $data['link'] = 'https://twitter.com/' . $tw_userdata->screen_name; $data['id'] = $tw_userdata->id; } break; } //if cart is empty or user is not logged in social media //and accessing the url then send back user to checkout page if (!isset($data['id']) || empty($data['id'])) { $redirect_url = $this->session->get('wps_deals_stcd_redirect_url'); if (!empty($redirect_url)) { $this->session->remove('wps_deals_stcd_redirect_url'); } wp_redirect($redirect_url); exit; //send user to checkout page //wps_deals_send_on_checkout_page(); } //when user will click submit button of custom login //check user clicks submit button of registration page and get parameter should be valid param if (isset($_POST['wps-deals-submit']) && !empty($_POST['wps-deals-submit']) && $_POST['wps-deals-submit'] == __('Register', 'wpsdeals')) { $loginurl = wp_login_url(); if (isset($_POST['wps_deals_social_email'])) { //check email is set or not $socialemail = $_POST['wps_deals_social_email']; if (empty($socialemail)) { //if email is empty $errors->add('empty_email', __('<strong>ERROR :</strong> Enter your email address.', 'wpsdeals')); } elseif (!is_email($socialemail)) { //if email is not valid $errors->add('invalid_email', __('<strong>ERROR :</strong> The email address did not validate.', 'wpsdeals')); $socialemail = ''; } elseif (email_exists($socialemail)) { //if email is exist or not $errors->add('email_exists', __('<strong>ERROR :</strong> Email already exists, If you have an account login first.', 'wpsdeals')); } if ($errors->get_error_code() == '') { // if (!empty($data)) { //check user data is not empty $data['email'] = $socialemail; //create user $usercreated = $this->wps_deals_social_create_user($data); //check shortcode redirect url is set and not empty then make it blank $redirect_url = $this->session->get('wps_deals_stcd_redirect_url'); if (!empty($redirect_url)) { $this->session->remove('wps_deals_stcd_redirect_url'); } wp_redirect($redirect_url); exit; //send user to checkout page //wps_deals_send_on_checkout_page(); } } } } //redirect user to custom registration form if (isset($_GET['wps_deals_social_login']) && !empty($_GET['wps_deals_social_login'])) { $prefix = WPS_DEALS_META_PREFIX; //login call back url after registration /*$callbackurl = wp_login_url(); $callbackurl = add_query_arg('wps_deals_social_login_done', 1, $callbackurl);*/ $socialemail = isset($_POST['wps_deals_social_email']) ? $_POST['wps_deals_social_email'] : ''; //check the user who is going to connect with site //it is alreay exist with same data or not //if user is exist then simply make that user logged in $metaquery = array(array('key' => $prefix . 'social_user_connect_via', 'value' => $data['type']), array('key' => $prefix . 'social_identifier', 'value' => $data['id'])); $getusers = get_users(array('meta_query' => $metaquery)); $wpuser = array_shift($getusers); //getting users //check user is exist or not conected with same metabox if (!empty($wpuser)) { //make user logged in wp_set_auth_cookie($wpuser->ID, false); //check shortcode redirect url is set and not empty then make it blank $redirect_url = $this->session->get('wps_deals_stcd_redirect_url'); if (!empty($redirect_url)) { $this->session->remove('wps_deals_stcd_redirect_url'); } wp_redirect($redirect_url); exit; //send user to checkout page //wps_deals_send_on_checkout_page(); } else { //if user is not exist then show register user form login_header(__('Registration Form', 'wpsdeals'), '<p class="message register">' . __('Please enter your email address to compelete registeration.', 'wpsdeals') . '</p>', $errors); ?> <form name="registerform" id="registerform" action="" method="post"> <p> <label for="wcsl_email"><?php _e('E-mail', 'wpsdeals'); ?> <br /> <input type="text" name="wps_deals_social_email" id="wps_deals_social_email" class="input" value="<?php echo $this->model->wps_deals_escape_attr($socialemail); ?> " size="25" tabindex="20" /></label> </p> <p id="reg_passmail"> <?php _e('Username and Password will be sent to your email.', 'wpsdeals'); ?> </p> <br class="clear" /> <p class="submit"><input type="submit" name="wps-deals-submit" id="wps-deals-submit" class="button-primary" value="<?php _e('Register', 'wpsdeals'); ?> " tabindex="100" /></p> </form> <?php login_footer('user_login'); exit; } } } }