/** * Add faq and user guide links to plugin_row_meta */ function wsl_add_plugin_row_meta($links, $file) { static $this_plugin; if (!$this_plugin) { $this_plugin = plugin_basename(__FILE__); } if ($file == $this_plugin) { $wsl_links = array('<a href="http://miled.github.io/wordpress-social-login/">' . _wsl__("Docs", 'wordpress-social-login') . '</a>', '<a href="http://miled.github.io/wordpress-social-login/support.html">' . _wsl__("Support", 'wordpress-social-login') . '</a>', '<a href="https://github.com/miled/wordpress-social-login">' . _wsl__("Fork me on Github", 'wordpress-social-login') . '</a>'); return array_merge($links, $wsl_links); } return $links; }
function wsl_process_login_authenticate_wp_user($user_id, $provider, $redirect_to, $adapter, $hybridauth_user_profile) { // There was a bug when this function received non-integer user_id and updated random users, let's be safe if (!is_integer($user_id)) { return wsl_render_notices_pages(_wsl__("Invalid user_id", 'wordpress-social-login')); } // calculate user age $user_age = $hybridauth_user_profile->age; // not that precise you say... well welcome to my world if (!$user_age && (int) $hybridauth_user_profile->birthYear) { $user_age = (int) date("Y") - (int) $hybridauth_user_profile->birthYear; } // update some stuff $newdata['user_id'] = $user_id; //not to be changed $newdata['user'] = $provider; $newdata['user_gender'] = $hybridauth_user_profile->gender; $newdata['user_age'] = $user_age; $newdata['user_image'] = $hybridauth_user_profile->photoURL; // HOOKABLE: $newdata = apply_filters('wsl_hook_process_login_alter_update_userdata', $newdata, $hybridauth_user_profile, $provider); update_user_meta($user_id, 'wsl_user', $newdata['user']); update_user_meta($user_id, 'wsl_user_gender', $newdata['user_gender']); update_user_meta($user_id, 'wsl_user_age', $newdata['user_age']); update_user_meta($user_id, 'wsl_user_image', $newdata['user_image']); // launch contact import if enabled wsl_import_user_contacts($provider, $adapter, $user_id); // store user hybridauth user profile if needed wsl_store_hybridauth_user_data($user_id, $provider, $hybridauth_user_profile); // Bouncer :: User Moderation : E-mail Confirmation — Yield to Theme My Login plugin if (get_option('wsl_settings_bouncer_new_users_moderation_level') == 101) { $redirect_to = site_url('wp-login.php', 'login_post') . (strpos(site_url('wp-login.php', 'login_post'), '?') ? '&' : '?') . "pending=activation"; @Theme_My_Login_User_Moderation::new_user_activation_notification($user_id); } elseif (get_option('wsl_settings_bouncer_new_users_moderation_level') == 102) { $redirect_to = site_url('wp-login.php', 'login_post') . (strpos(site_url('wp-login.php', 'login_post'), '?') ? '&' : '?') . "pending=approval"; } else { // HOOKABLE: do_action("wsl_hook_process_login_before_set_auth_cookie", $user_id, $provider, $hybridauth_user_profile); // That's it. create a session for user_id and redirect him to redirect_to wp_set_auth_cookie($user_id); } // HOOKABLE: do_action("wsl_hook_process_login_before_redirect", $user_id, $provider, $hybridauth_user_profile); wp_safe_redirect($redirect_to); exit; }
function wsl_component_users_profiles($user_id) { // HOOKABLE: do_action("wsl_component_users_profiles_start"); $assets_base_url = WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL . 'assets/img/16x16/'; $linked_accounts = wsl_get_stored_hybridauth_user_profiles_by_user_id($user_id); // is it a WSL user? if (!$linked_accounts) { ?> <div style="padding: 15px; margin-bottom: 8px; border: 1px solid #ddd; background-color: #fff;box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);"> <?php _wsl_e("This's not a WSL user!", 'wordpress-social-login'); ?> . </div> <?php return; } # http://hybridauth.sourceforge.net/userguide/Profile_Data_User_Profile.html $ha_profile_fields = array(array('field' => 'identifier', 'label' => _wsl__("Provider user ID", 'wordpress-social-login'), 'description' => _wsl__("The Unique user's ID on the connected provider. Depending on the provider, this field can be an number, Email, URL, etc", 'wordpress-social-login')), array('field' => 'profileURL', 'label' => _wsl__("Profile URL", 'wordpress-social-login'), 'description' => _wsl__("Link to the user profile on the provider web site", 'wordpress-social-login')), array('field' => 'webSiteURL', 'label' => _wsl__("Website URL", 'wordpress-social-login'), 'description' => _wsl__("User website, blog or web page", 'wordpress-social-login')), array('field' => 'photoURL', 'label' => _wsl__("Photo URL", 'wordpress-social-login'), 'description' => _wsl__("Link to user picture or avatar on the provider web site", 'wordpress-social-login')), array('field' => 'displayName', 'label' => _wsl__("Display name", 'wordpress-social-login'), 'description' => _wsl__("User Display name. If not provided by social network, WSL will return a concatenation of the user first and last name", 'wordpress-social-login')), array('field' => 'description', 'label' => _wsl__("Description", 'wordpress-social-login'), 'description' => _wsl__("A short about me", 'wordpress-social-login')), array('field' => 'firstName', 'label' => _wsl__("First name", 'wordpress-social-login'), 'description' => _wsl__("User's first name", 'wordpress-social-login')), array('field' => 'lastName', 'label' => _wsl__("Last name", 'wordpress-social-login'), 'description' => _wsl__("User's last name", 'wordpress-social-login')), array('field' => 'gender', 'label' => _wsl__("Gender", 'wordpress-social-login'), 'description' => _wsl__("User's gender. Values are 'female', 'male' or blank", 'wordpress-social-login')), array('field' => 'language', 'label' => _wsl__("Language", 'wordpress-social-login'), 'description' => _wsl__("User's language", 'wordpress-social-login')), array('field' => 'age', 'label' => _wsl__("Age", 'wordpress-social-login'), 'description' => _wsl__("User' age. Note that WSL do not calculate this field. We return it as it was provided", 'wordpress-social-login')), array('field' => 'birthDay', 'label' => _wsl__("Birth day", 'wordpress-social-login'), 'description' => _wsl__("The day in the month in which the person was born. Not to confuse it with 'Birth date'", 'wordpress-social-login')), array('field' => 'birthMonth', 'label' => _wsl__("Birth month", 'wordpress-social-login'), 'description' => _wsl__("The month in which the person was born", 'wordpress-social-login')), array('field' => 'birthYear', 'label' => _wsl__("Birth year", 'wordpress-social-login'), 'description' => _wsl__("The year in which the person was born", 'wordpress-social-login')), array('field' => 'email', 'label' => _wsl__("Email", 'wordpress-social-login'), 'description' => _wsl__("User's email address. Note: some providers like Facebook and Google can provide verified emails. Users with the same verified email will be automatically linked", 'wordpress-social-login')), array('field' => 'phone', 'label' => _wsl__("Phone", 'wordpress-social-login'), 'description' => _wsl__("User's phone number", 'wordpress-social-login')), array('field' => 'address', 'label' => _wsl__("Address", 'wordpress-social-login'), 'description' => _wsl__("User's address", 'wordpress-social-login')), array('field' => 'country', 'label' => _wsl__("Country", 'wordpress-social-login'), 'description' => _wsl__("User's country", 'wordpress-social-login')), array('field' => 'region', 'label' => _wsl__("Region", 'wordpress-social-login'), 'description' => _wsl__("User's state or region", 'wordpress-social-login')), array('field' => 'city', 'label' => _wsl__("City", 'wordpress-social-login'), 'description' => _wsl__("User's city", 'wordpress-social-login')), array('field' => 'zip', 'label' => _wsl__("Zip", 'wordpress-social-login'), 'description' => _wsl__("User's zipcode", 'wordpress-social-login'))); $user_data = get_userdata($user_id); add_thickbox(); $actions = array('edit_details' => '<a class="button button-secondary thickbox" href="' . admin_url('user-edit.php?user_id=' . $user_id . '&TB_iframe=true&width=1150&height=550') . '">' . _wsl__('Edit user details', 'wordpress-social-login') . '</a>', 'show_contacts' => '<a class="button button-secondary" href="' . admin_url('options-general.php?page=wordpress-social-login&wslp=contacts&uid=' . $user_id) . '">' . _wsl__('Show user contacts list', 'wordpress-social-login') . '</a>'); // HOOKABLE: $actions = apply_filters('wsl_component_users_profiles_alter_actions_list', $actions, $user_id); ?> <style> table td, table th { border: 1px solid #DDDDDD; } table th label { font-weight: bold; } .form-table th { width:120px; text-align:right; } p.description { font-size: 11px ! important; margin:0 ! important;} </style> <script> function confirmDeleteWSLUser() { return confirm( <?php echo json_encode(_wsl__("Are you sure you want to delete the user's social profiles and contacts?\n\nNote: The associated WordPress user won't be deleted.", 'wordpress-social-login')); ?> ); } </script> <div style="margin-top: 15px;padding: 15px; margin-bottom: 8px; border: 1px solid #ddd; background-color: #fff;box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);"> <h3 style="margin:0;"><?php echo sprintf(_wsl__("%s's social profiles", 'wordpress-social-login'), $user_data->display_name); ?> </h3> <p style="float: <?php if (is_rtl()) { echo 'left'; } else { echo 'right'; } ?> ;margin-top:-23px"> <?php echo implode(' ', $actions); ?> </p> </div> <div style="padding: 20px; border: 1px solid #ddd; background-color: #fff;"> <table class="wp-list-table widefat"> <tr><th width="200"><label><?php _wsl_e("Wordpress User ID", 'wordpress-social-login'); ?> </label></th><td><?php echo $user_data->ID; ?> </td></tr> <tr><th width="200"><label><?php _wsl_e("Username", 'wordpress-social-login'); ?> </label></th><td><?php echo $user_data->user_login; ?> </td></tr> <tr><th><label><?php _wsl_e("Display name", 'wordpress-social-login'); ?> </label></th><td><?php echo $user_data->display_name; ?> </td></tr> <tr><th><label><?php _wsl_e("E-mail", 'wordpress-social-login'); ?> </label></th><td><a href="mailto:<?php echo $user_data->user_email; ?> " target="_blank"><?php echo $user_data->user_email; ?> </a></td></tr> <tr><th><label><?php _wsl_e("Website", 'wordpress-social-login'); ?> </label></th><td><a href="<?php echo $user_data->user_url; ?> " target="_blank"><?php echo $user_data->user_url; ?> </a></td></tr> <tr><th><label><?php _wsl_e("Registered", 'wordpress-social-login'); ?> </label></th><td><?php echo $user_data->user_registered; ?> </td></tr> </tr> </table> </div> <?php foreach ($linked_accounts as $link) { ?> <div style="margin-top:15px;padding: 5px 20px 20px; border: 1px solid #ddd; background-color: #fff;"> <h4><img src="<?php echo $assets_base_url . strtolower($link->provider) . '.png'; ?> " style="vertical-align:top;width:16px;height:16px;" /> <?php _wsl_e("User profile", 'wordpress-social-login'); ?> <small><?php echo sprintf(_wsl__("as provided by %s", 'wordpress-social-login'), $link->provider); ?> </small></h4> <table class="wp-list-table widefat"> <?php $profile_fields = (array) $link; foreach ($ha_profile_fields as $item) { $item['field'] = strtolower($item['field']); ?> <tr> <th width="200"> <label><?php echo $item['label']; ?> </label> </th> <td> <?php if (isset($profile_fields[$item['field']]) && $profile_fields[$item['field']]) { $field_value = $profile_fields[$item['field']]; if (in_array($item['field'], array('profileurl', 'websiteurl', 'email'))) { ?> <a href="<?php if ($item['field'] == 'email') { echo 'mailto:'; } echo $field_value; ?> " target="_blank"><?php echo $field_value; ?> </a> <?php } elseif ($item['field'] == 'photourl') { ?> <a href="<?php echo $field_value; ?> " target="_blank"><img width="36" height="36" align="left" src="<?php echo $field_value; ?> " style="margin-right: 5px;" > <?php echo $field_value; ?> </a> <?php } else { echo $field_value; } ?> <p class="description"> <?php echo $item['description']; ?> . </p> <?php } ?> </td> </tr> <?php } ?> </table> </div> <?php } // HOOKABLE: do_action("wsl_component_users_profiles_end"); }
function wsl_component_buddypress_setup_profile_mapping() { $assets_base_url = WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL . 'assets/img/'; $wsl_settings_buddypress_enable_mapping = get_option('wsl_settings_buddypress_enable_mapping'); $wsl_settings_buddypress_xprofile_map = get_option('wsl_settings_buddypress_xprofile_map'); # http://hybridauth.sourceforge.net/userguide/Profile_Data_User_Profile.html $ha_profile_fields = array(array('field' => 'provider', 'label' => _wsl__("Provider name", 'wordpress-social-login'), 'description' => _wsl__("The the provider or social network name the user used to connected", 'wordpress-social-login')), array('field' => 'identifier', 'label' => _wsl__("Provider user Identifier", 'wordpress-social-login'), 'description' => _wsl__("The Unique user's ID on the connected provider. Depending on the provider, this field can be an number, Email, URL, etc", 'wordpress-social-login')), array('field' => 'profileURL', 'label' => _wsl__("Profile URL", 'wordpress-social-login'), 'description' => _wsl__("Link to the user profile on the provider web site", 'wordpress-social-login')), array('field' => 'webSiteURL', 'label' => _wsl__("Website URL", 'wordpress-social-login'), 'description' => _wsl__("User website, blog or web page", 'wordpress-social-login')), array('field' => 'photoURL', 'label' => _wsl__("Photo URL", 'wordpress-social-login'), 'description' => _wsl__("Link to user picture or avatar on the provider web site", 'wordpress-social-login')), array('field' => 'displayName', 'label' => _wsl__("Display name", 'wordpress-social-login'), 'description' => _wsl__("User Display name. If not provided by social network, WSL will return a concatenation of the user first and last name", 'wordpress-social-login')), array('field' => 'description', 'label' => _wsl__("Description", 'wordpress-social-login'), 'description' => _wsl__("A short about me", 'wordpress-social-login')), array('field' => 'firstName', 'label' => _wsl__("First name", 'wordpress-social-login'), 'description' => _wsl__("User's first name", 'wordpress-social-login')), array('field' => 'lastName', 'label' => _wsl__("Last name", 'wordpress-social-login'), 'description' => _wsl__("User's last name", 'wordpress-social-login')), array('field' => 'gender', 'label' => _wsl__("Gender", 'wordpress-social-login'), 'description' => _wsl__("User's gender. Values are 'female', 'male' or blank", 'wordpress-social-login')), array('field' => 'language', 'label' => _wsl__("Language", 'wordpress-social-login'), 'description' => _wsl__("User's language", 'wordpress-social-login')), array('field' => 'age', 'label' => _wsl__("Age", 'wordpress-social-login'), 'description' => _wsl__("User' age. Note that WSL do not calculate this field. We return it as it was provided", 'wordpress-social-login')), array('field' => 'birthDay', 'label' => _wsl__("Birth day", 'wordpress-social-login'), 'description' => _wsl__("The day in the month in which the person was born. Not to confuse it with 'Birth date'", 'wordpress-social-login')), array('field' => 'birthMonth', 'label' => _wsl__("Birth month", 'wordpress-social-login'), 'description' => _wsl__("The month in which the person was born", 'wordpress-social-login')), array('field' => 'birthYear', 'label' => _wsl__("Birth year", 'wordpress-social-login'), 'description' => _wsl__("The year in which the person was born", 'wordpress-social-login')), array('field' => 'birthDate', 'label' => _wsl__("Birth date", 'wordpress-social-login'), 'description' => _wsl__("Complete birthday in which the person was born. Format: YYYY-MM-DD", 'wordpress-social-login')), array('field' => 'email', 'label' => _wsl__("Email", 'wordpress-social-login'), 'description' => _wsl__("User's email address. Not all of provider grant access to the user email", 'wordpress-social-login')), array('field' => 'phone', 'label' => _wsl__("Phone", 'wordpress-social-login'), 'description' => _wsl__("User's phone number", 'wordpress-social-login')), array('field' => 'address', 'label' => _wsl__("Address", 'wordpress-social-login'), 'description' => _wsl__("User's address", 'wordpress-social-login')), array('field' => 'country', 'label' => _wsl__("Country", 'wordpress-social-login'), 'description' => _wsl__("User's country", 'wordpress-social-login')), array('field' => 'region', 'label' => _wsl__("Region", 'wordpress-social-login'), 'description' => _wsl__("User's state or region", 'wordpress-social-login')), array('field' => 'city', 'label' => _wsl__("City", 'wordpress-social-login'), 'description' => _wsl__("User's city", 'wordpress-social-login')), array('field' => 'zip', 'label' => _wsl__("Zip", 'wordpress-social-login'), 'description' => _wsl__("User's zipcode", 'wordpress-social-login'))); ?> <div class="stuffbox"> <h3> <label><?php _wsl_e("Profile mappings", 'wordpress-social-login'); ?> </label> </h3> <div class="inside"> <p> <?php _wsl_e("When <b>Profile mapping</b> is enabled, WSL will try to automatically fill in Buddypress users profiles from their social networks profiles", 'wordpress-social-login'); ?> . </p> <p> <b><?php _wsl_e('Notes', 'wordpress-social-login'); ?> :</b> </p> <p class="description"> 1. <?php _wsl_e('<b>Profile mapping</b> will only work for new users. Profile mapping for returning users will implemented in future version of WSL', 'wordpress-social-login'); ?> . <br /> 2. <?php _wsl_e('Not all the mapped fields will be filled. Some providers and social networks do not give away many information about their users', 'wordpress-social-login'); ?> . <br /> 3. <?php _wsl_e('WSL can only map <b>Single Fields</b>. Supported fields types are: Multi-line Text Areax, Text Box, URL, Date Selector and Number', 'wordpress-social-login'); ?> . </p> <table width="100%" border="0" cellpadding="5" cellspacing="2" style="border-top:1px solid #ccc;"> <tr> <td width="200" align="right"><strong><?php _wsl_e("Enable profile mapping", 'wordpress-social-login'); ?> :</strong></td> <td> <select name="wsl_settings_buddypress_enable_mapping" id="wsl_settings_buddypress_enable_mapping" style="width:100px" onChange="toggleMapDiv();"> <option <?php if ($wsl_settings_buddypress_enable_mapping == 1) { echo "selected"; } ?> value="1"><?php _wsl_e("Yes", 'wordpress-social-login'); ?> </option> <option <?php if ($wsl_settings_buddypress_enable_mapping == 2) { echo "selected"; } ?> value="2"><?php _wsl_e("No", 'wordpress-social-login'); ?> </option> </select> </td> </tr> </table> <br> </div> </div> <div id="xprofilemapdiv" class="stuffbox" style="<?php if ($wsl_settings_buddypress_enable_mapping == 2) { echo "display:none;"; } ?> "> <h3> <label><?php _wsl_e("Fields Map", 'wordpress-social-login'); ?> </label> </h3> <div class="inside"> <p> <?php _wsl_e("Here you can create a new map by placing WSL users profiles fields to the appropriate destination fields", 'wordpress-social-login'); ?> . <?php _wsl_e('The left column shows the available <b>WSL users profiles fields</b>: These select boxes are called <b>source</b> fields', 'wordpress-social-login'); ?> . <?php _wsl_e('The right column shows the list of <b>Buddypress profiles fields</b>: Those are the <b>destination</b> fields', 'wordpress-social-login'); ?> . <?php _wsl_e('If you don\'t want to map a particular Buddypress field, then leave the source for that field blank', 'wordpress-social-login'); ?> . </p> <hr /> <?php if (bp_has_profile()) { while (bp_profile_groups()) { global $group; bp_the_profile_group(); ?> <h4><?php echo sprintf(_wsl__("Fields Group '%s'", 'wordpress-social-login'), $group->name); ?> :</h4> <table width="100%" border="0" cellpadding="5" cellspacing="2" style="border-top:1px solid #ccc;"> <?php while (bp_profile_fields()) { global $field; bp_the_profile_field(); ?> <tr> <td width="270" align="right" valign="top"> <?php $map = isset($wsl_settings_buddypress_xprofile_map[$field->id]) ? $wsl_settings_buddypress_xprofile_map[$field->id] : 0; $can_map_it = true; if (!in_array($field->type, array('textarea', 'textbox', 'url', 'datebox', 'number'))) { $can_map_it = false; } ?> <select name="wsl_settings_buddypress_xprofile_map[<?php echo $field->id; ?> ]" style="width:255px" id="bb_profile_mapping_selector_<?php echo $field->id; ?> " onChange="showMappingConfirm( <?php echo $field->id; ?> );" <?php if (!$can_map_it) { echo "disabled"; } ?> > <option value=""></option> <?php if ($can_map_it) { foreach ($ha_profile_fields as $item) { ?> <option value="<?php echo $item['field']; ?> " <?php if ($item['field'] == $map) { echo "selected"; } ?> ><?php echo $item['label']; ?> </option> <?php } } ?> </select> </td> <td valign="top" align="center" width="50"> <img src="<?php echo $assets_base_url; ?> arr_right.png" /> </td> <td valign="top"> <strong><?php echo $field->name; ?> </strong> <?php if (!$can_map_it) { ?> <p class="description"> <?php _wsl_e("<b>WSL</b> can not map this field. Supported field types are: <em>Multi-line Text Areax, Text Box, URL, Date Selector and Number</em>", 'wordpress-social-login'); ?> . </p> <?php } else { ?> <?php foreach ($ha_profile_fields as $item) { ?> <p class="description bb_profile_mapping_confirm_<?php echo $field->id; ?> " style="margin-left:0;<?php if ($item['field'] != $map) { echo "display:none;"; } ?> " id="bb_profile_mapping_confirm_<?php echo $field->id; ?> _<?php echo $item['field']; ?> "> <?php echo sprintf(_wsl__("WSL <b>%s</b> is mapped to Buddypress <b>%s</b> field", 'wordpress-social-login'), $item['label'], $field->name); ?> . <br /> <em><b><?php echo $item['label']; ?> :</b> <?php echo $item['description']; ?> .</em> </p> <?php } ?> <?php } ?> </td> </tr> <?php } ?> </table> <?php } } ?> </div> </div> <script> function toggleMapDiv(){ if(typeof jQuery=="undefined"){ alert( "Error: WordPress Social Login require jQuery to be installed on your wordpress in order to work!" ); return false; } var em = jQuery( "#wsl_settings_buddypress_enable_mapping" ).val(); if( em == 2 ) jQuery( "#xprofilemapdiv" ).hide(); else jQuery( "#xprofilemapdiv" ).show(); } function showMappingConfirm( field ){ if(typeof jQuery=="undefined"){ alert( "Error: WordPress Social Login require jQuery to be installed on your wordpress in order to work!" ); return false; } var el = jQuery( "#bb_profile_mapping_selector_" + field ).val(); jQuery( ".bb_profile_mapping_confirm_" + field ).hide(); jQuery( "#bb_profile_mapping_confirm_" + field + "_" + el ).show(); } </script> <?php }
/** * This should be reworked somehow.. the code has become spaghettis */ function wsl_component_networks_setup() { // HOOKABLE: do_action("wsl_component_networks_setup_start"); global $WORDPRESS_SOCIAL_LOGIN_PROVIDERS_CONFIG; $assets_base_url = WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL . 'assets/img/16x16/'; $assets_setup_base_url = WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL . 'assets/img/setup/'; // save settings? if (isset($_REQUEST["enable"]) && $_REQUEST["enable"]) { $provider_id = $_REQUEST["enable"]; update_option('wsl_settings_' . $provider_id . '_enabled', 1); } ?> <script> function toggleproviderkeys(idp) { if(typeof jQuery=="undefined") { alert( "Error: WordPress Social Login require jQuery to be installed on your wordpress in order to work!" ); return; } if(jQuery('#wsl_settings_' + idp + '_enabled').val()==1) { jQuery('.wsl_tr_settings_' + idp).show(); } else { jQuery('.wsl_tr_settings_' + idp).hide(); jQuery('.wsl_div_settings_help_' + idp).hide(); } return false; } function toggleproviderhelp(idp) { if(typeof jQuery=="undefined") { alert( "Error: WordPress Social Login require jQuery to be installed on your wordpress in order to work!" ); return false; } jQuery('.wsl_div_settings_help_' + idp).toggle(); return false; } </script> <?php foreach ($WORDPRESS_SOCIAL_LOGIN_PROVIDERS_CONFIG as $item) { $provider_id = isset($item["provider_id"]) ? $item["provider_id"] : ''; $provider_name = isset($item["provider_name"]) ? $item["provider_name"] : ''; $require_client_id = isset($item["require_client_id"]) ? $item["require_client_id"] : ''; $require_api_key = isset($item["require_api_key"]) ? $item["require_api_key"] : ''; $default_api_scope = isset($item["default_api_scope"]) ? $item["default_api_scope"] : ''; $provide_email = isset($item["provide_email"]) ? $item["provide_email"] : ''; $provider_new_app_link = isset($item["new_app_link"]) ? $item["new_app_link"] : ''; $provider_userguide_section = isset($item["userguide_section"]) ? $item["userguide_section"] : ''; $provider_callback_url = ""; if (!(isset($item["default_network"]) && $item["default_network"] || get_option('wsl_settings_' . $provider_id . '_enabled'))) { continue; } // default endpoint_url $endpoint_url = WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL; if (isset($item["callback"]) && $item["callback"]) { $provider_callback_url = '<span style="color:green">' . $endpoint_url . '?hauth.done=' . $provider_id . '</span>'; } if (isset($item["custom_callback"]) && $item["custom_callback"]) { $provider_callback_url = '<span style="color:green">' . $endpoint_url . 'endpoints/' . strtolower($provider_id) . '.php</span>'; } $setupsteps = 0; ?> <a name="setup<?php echo strtolower($provider_id); ?> "></a> <div class="stuffbox" id="namediv"> <h3> <label class="wp-neworks-label"> <img alt="<?php echo $provider_name; ?> " title="<?php echo $provider_name; ?> " src="<?php echo $assets_base_url . strtolower($provider_id) . '.png'; ?> " style="vertical-align: top;width:16px;height:16px;" /> <?php _wsl_e($provider_name, 'wordpress-social-login'); ?> </label> </h3> <div class="inside"> <table class="form-table editcomment"> <tbody> <tr> <td style="width:125px"><?php _wsl_e("Enabled", 'wordpress-social-login'); ?> :</td> <td> <select name="<?php echo 'wsl_settings_' . $provider_id . '_enabled'; ?> " id="<?php echo 'wsl_settings_' . $provider_id . '_enabled'; ?> " onChange="toggleproviderkeys('<?php echo $provider_id; ?> ')" > <option value="1" <?php if (get_option('wsl_settings_' . $provider_id . '_enabled')) { echo "selected"; } ?> ><?php _wsl_e("Yes", 'wordpress-social-login'); ?> </option> <option value="0" <?php if (!get_option('wsl_settings_' . $provider_id . '_enabled')) { echo "selected"; } ?> ><?php _wsl_e("No", 'wordpress-social-login'); ?> </option> </select> </td> <td style="width:160px"> </td> </tr> <?php if ($provider_new_app_link) { ?> <?php if ($require_client_id) { // key or id ? ?> <tr valign="top" <?php if (!get_option('wsl_settings_' . $provider_id . '_enabled')) { echo 'style="display:none"'; } ?> class="wsl_tr_settings_<?php echo $provider_id; ?> " > <td><?php _wsl_e("Application ID", 'wordpress-social-login'); ?> :</td> <td><input dir="ltr" type="text" name="<?php echo 'wsl_settings_' . $provider_id . '_app_id'; ?> " value="<?php echo get_option('wsl_settings_' . $provider_id . '_app_id'); ?> " ></td> <td><a href="javascript:void(0)" onClick="toggleproviderhelp('<?php echo $provider_id; ?> ')"><?php _wsl_e("Where do I get this info?", 'wordpress-social-login'); ?> </a></td> </tr> <?php } else { ?> <tr valign="top" <?php if (!get_option('wsl_settings_' . $provider_id . '_enabled')) { echo 'style="display:none"'; } ?> class="wsl_tr_settings_<?php echo $provider_id; ?> " > <td><?php _wsl_e("Application Key", 'wordpress-social-login'); ?> :</td> <td><input dir="ltr" type="text" name="<?php echo 'wsl_settings_' . $provider_id . '_app_key'; ?> " value="<?php echo get_option('wsl_settings_' . $provider_id . '_app_key'); ?> " ></td> <td><a href="javascript:void(0)" onClick="toggleproviderhelp('<?php echo $provider_id; ?> ')"><?php _wsl_e("Where do I get this info?", 'wordpress-social-login'); ?> </a></td> </tr> <?php } ?> <?php if (!$require_api_key) { ?> <tr valign="top" <?php if (!get_option('wsl_settings_' . $provider_id . '_enabled')) { echo 'style="display:none"'; } ?> class="wsl_tr_settings_<?php echo $provider_id; ?> " > <td><?php _wsl_e("Application Secret", 'wordpress-social-login'); ?> :</td> <td><input dir="ltr" type="text" name="<?php echo 'wsl_settings_' . $provider_id . '_app_secret'; ?> " value="<?php echo get_option('wsl_settings_' . $provider_id . '_app_secret'); ?> " ></td> <td><a href="javascript:void(0)" onClick="toggleproviderhelp('<?php echo $provider_id; ?> ')"><?php _wsl_e("Where do I get this info?", 'wordpress-social-login'); ?> </a></td> </tr> <?php } ?> <?php if (get_option('wsl_settings_development_mode_enabled')) { ?> <?php if ($default_api_scope) { ?> <tr valign="top" <?php if (!get_option('wsl_settings_' . $provider_id . '_enabled')) { echo 'style="display:none"'; } ?> class="wsl_tr_settings_<?php echo $provider_id; ?> " > <td><?php _wsl_e("Application Scope", 'wordpress-social-login'); ?> :</td> <td><input dir="ltr" type="text" name="<?php echo 'wsl_settings_' . $provider_id . '_app_scope'; ?> " value="<?php echo get_option('wsl_settings_' . $provider_id . '_app_scope'); ?> " ></td> </tr> <?php } ?> <?php if ($provider_callback_url) { ?> <tr valign="top" <?php if (!get_option('wsl_settings_' . $provider_id . '_enabled')) { echo 'style="display:none"'; } ?> class="wsl_tr_settings_<?php echo $provider_id; ?> " > <td><?php _wsl_e("Callback URL", 'wordpress-social-login'); ?> :</td> <td><input dir="ltr" type="text" name="" value="<?php echo strip_tags($provider_callback_url); ?> " readonly="readonly"></td> </tr> <?php } ?> <?php } ?> <?php } // if require registration ?> </tbody> </table> <?php if (get_option('wsl_settings_' . $provider_id . '_enabled')) { ?> <?php if ($provider_id == "Steam") { ?> <div class="fade updated"> <p> <b><?php _wsl_e("Notes", 'wordpress-social-login'); ?> :</b> </p> <p> 1. <?php echo sprintf(_wsl__("<b>%s</b> do not require an external application, however if the Web API Key is provided, then WSL will be able to get more information about the connected %s users", 'wordpress-social-login'), $provider_name, $provider_name); ?> . <br />2. <?php echo sprintf(_wsl__("<b>%s</b> do not provide their user's email address and by default a random email will then be generated for them instead", 'wordpress-social-login'), $provider_name); ?> . <?php _wsl_e('To change this behaviour and to force new registered users to provide their emails before they get in, goto <b><a href="options-general.php?page=wordpress-social-login&wslp=bouncer">Bouncer</a></b> and enable <b>Profile Completion</b>', 'wordpress-social-login'); ?> . </p> </div> <?php } elseif ($provider_new_app_link && strlen(trim(get_option('wsl_settings_' . $provider_id . '_app_secret'))) == 0) { ?> <div class="fade error"> <p> <?php echo sprintf(_wsl__('<b>%s</b> requires that you create an external application linking your website to their API. To know how to create this application, click on “Where do I get this info?” and follow the steps', 'wordpress-social-login'), $provider_name, $provider_name); ?> . </p> </div> <?php } elseif (in_array($provider_id, array("Twitter", "Identica", "Tumblr", "Goodreads", "500px", "Vkontakte", "Gowalla", "Steam"))) { ?> <div class="fade updated"> <p> <b><?php _wsl_e("Note", 'wordpress-social-login'); ?> :</b> <?php echo sprintf(_wsl__("<b>%s</b> do not provide their user's email address and by default a random email will then be generated for them instead", 'wordpress-social-login'), $provider_name); ?> . <?php _wsl_e('To change this behaviour and to force new registered users to provide their emails before they get in, goto <b><a href="options-general.php?page=wordpress-social-login&wslp=bouncer">Bouncer</a></b> and enable <b>Profile Completion</b>', 'wordpress-social-login'); ?> . </p> </div> <?php } ?> <?php } ?> <br /> <div class="wsl_div_settings_help_<?php echo $provider_id; ?> " style="<?php if (isset($_REQUEST["enable"]) && !isset($_REQUEST["settings-updated"]) && $_REQUEST["enable"] == $provider_id) { echo "-"; } // <= lolz ?> display:none;" > <hr class="wsl" /> <?php if ($provider_id == "Steam") { ?> <?php } elseif ($provider_new_app_link) { ?> <?php _wsl_e('<span style="color:#CB4B16;">Application</span> id and secret (also sometimes referred as <span style="color:#CB4B16;">Consumer</span> key and secret or <span style="color:#CB4B16;">Client</span> id and secret) are what we call an application credentials', 'wordpress-social-login'); ?> . <?php echo sprintf(_wsl__('This application will link your website <code>%s</code> to <code>%s API</code> and these credentials are needed in order for <b>%s</b> users to access your website', 'wordpress-social-login'), $_SERVER["SERVER_NAME"], $provider_name, $provider_name); ?> . <br /> <?php _wsl_e("These credentials may also differ in format, name and content depending on the social network.", 'wordpress-social-login'); ?> <br /> <br /> <?php echo sprintf(_wsl__('To enable authentication with this provider and to register a new <b>%s API Application</b>, follow the steps', 'wordpress-social-login'), $provider_name); ?> :<br /> <?php } else { ?> <p><?php echo sprintf(_wsl__('<b>Done.</b> Nothing more required for <b>%s</b>', 'wordpress-social-login'), $provider_name); ?> .</p> <?php } ?> <div style="margin-left:40px;"> <?php if ($provider_new_app_link) { ?> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> <?php echo sprintf(_wsl__('First go to: <a href="%s" target ="_blank">%s</a>', 'wordpress-social-login'), $provider_new_app_link, $provider_new_app_link); ?> </p> <?php if ($provider_id == "Google") { ?> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> <?php _wsl_e('On the <b>Dashboard sidebar</b> click on <b>Project</b> then click <em style="color:#0147bb;">“Create Project”</em>', 'wordpress-social-login'); ?> .</p> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> <?php _wsl_e("Once the project is created. Select that project, then <b>APIs & auth</b> > <b>Consent screen</b> and fill the required information", 'wordpress-social-login'); ?> .</p> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> <?php _wsl_e('Then <b>APIs & auth</b> > <b>APIs</b> and enable <em style="color:#0147bb;">“Google+ API”</em>. If you want to import the user contatcs enable <em style="color:#0147bb;">“Contacts API”</em> as well', 'wordpress-social-login'); ?> .</p> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> <?php _wsl_e("After that you will need to create an new application: <b>APIs & auth</b> > <b>Credentials</b> and then click <em style=\"color:#0147bb;\">“Create new Client ID”</em>", 'wordpress-social-login'); ?> .</p> </p> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> <?php _wsl_e("On the <b>“Create Client ID”</b> popup", 'wordpress-social-login'); ?> :</p> <ul style="margin-left:35px"> <li><?php _wsl_e('Select <em style="color:#0147bb;">“Web application”</em> as your application type', 'wordpress-social-login'); ?> .</li> <li><?php _wsl_e("Put your website domain in the <b>Authorized JavaScript origins</b> field. This should match with the current hostname", 'wordpress-social-login'); ?> <em style="color:#CB4B16;"><?php echo $_SERVER["SERVER_NAME"]; ?> </em>.</li> <li><?php _wsl_e("Provide this URL as the <b>Authorized redirect URI</b> for your application", 'wordpress-social-login'); ?> : <br /><?php echo $provider_callback_url; ?> </li> </ul> <?php } elseif ($provider_id == "Facebook") { ?> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> <?php _wsl_e("Select <b>Add a New App</b> from the <b>Apps</b> menu at the top", 'wordpress-social-login'); ?> .</p> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> <?php _wsl_e("Fill out Display Name, Namespace, choose a category and click <b>Create App</b>", 'wordpress-social-login'); ?> .</p> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> <?php _wsl_e("Go to Settings page and click on <b>Add Platform</b>. Choose website and enter in the new screen your website url in <b>App Domains</b> and <b>Site URL</b> fields", 'wordpress-social-login'); ?> . <?php _wsl_e("They should match with the current hostname", 'wordpress-social-login'); ?> <em style="color:#CB4B16;"><?php echo $_SERVER["SERVER_NAME"]; ?> </em>.</p> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> <?php _wsl_e("Go to the <b>Status & Review</b> page and choose <b>yes</b> where it says <b>Do you want to make this app and all its live features available to the general public?</b>", 'wordpress-social-login'); ?> .</p> <?php } else { ?> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> <?php _wsl_e("Create a new application", 'wordpress-social-login'); ?> .</p> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> <?php _wsl_e("Fill out any required fields such as the application name and description", 'wordpress-social-login'); ?> .</p> <?php } ?> <?php if ($provider_callback_url && $provider_id != "Google" && $provider_id != "Facebook") { ?> <p> <?php echo "<b>" . ++$setupsteps . "</b>."; ?> <?php _wsl_e("Provide this URL as the <b>Callback URL</b> for your application", 'wordpress-social-login'); ?> : <br /> <?php echo $provider_callback_url; ?> </p> <?php } ?> <?php if ($provider_id == "Live") { ?> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> <?php _wsl_e("Put your website domain in the <b>Redirect Domain</b> field. This should match with the current hostname", 'wordpress-social-login'); ?> <em style="color:#CB4B16;"><?php echo $_SERVER["SERVER_NAME"]; ?> </em>.</p> <?php } ?> <?php if ($provider_id == "LinkedIn") { ?> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> <?php _wsl_e('Choose <b>Live</b> on <b>Live Status</b>.', 'wordpress-social-login'); ?> </p> <?php } ?> <?php if ($provider_id == "Google") { ?> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> <?php _wsl_e("Once you have registered past the created application credentials (Client ID and Secret) into the boxes above", 'wordpress-social-login'); ?> .</p> <?php } elseif ($provider_id == "Twitter") { ?> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> <?php _wsl_e("Once you have registered, past the created application credentials (Consumer Key and Secret) into the boxes above", 'wordpress-social-login'); ?> .</p> <?php } elseif ($provider_id == "Facebook") { ?> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> <?php _wsl_e("Go back to the <b>Dashboard</b> page and past the created application credentials (APP ID and Secret) into the boxes above", 'wordpress-social-login'); ?> .</p> <?php } else { ?> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> <?php _wsl_e("Once you have registered, past the created application credentials into the boxes above", 'wordpress-social-login'); ?> .</p> <?php } ?> <?php } ?> <?php if ($provider_id == "Facebook") { ?> <table style="text-align: center;margin-bottom:12px;"> <td><a class="span4 thumbnail" href="<?php echo $assets_setup_base_url . 'facebook/1.png'; ?> " target="_blank"><img src="<?php echo $assets_setup_base_url . 'facebook/1.png'; ?> "></a></td> <td><a class="span4 thumbnail" href="<?php echo $assets_setup_base_url . 'facebook/2.png'; ?> " target="_blank"><img src="<?php echo $assets_setup_base_url . 'facebook/2.png'; ?> "></a></td> <td><a class="span4 thumbnail" href="<?php echo $assets_setup_base_url . 'facebook/3.png'; ?> " target="_blank"><img src="<?php echo $assets_setup_base_url . 'facebook/3.png'; ?> "></a></td> </table> <?php } ?> <?php if ($provider_id == "Google") { ?> <table style="text-align: center;margin-bottom:12px;"> <td><a class="span4 thumbnail" href="<?php echo $assets_setup_base_url . 'google/1.png'; ?> " target="_blank"><img src="<?php echo $assets_setup_base_url . 'google/1.png'; ?> "></a></td> <td><a class="span4 thumbnail" href="<?php echo $assets_setup_base_url . 'google/2.png'; ?> " target="_blank"><img src="<?php echo $assets_setup_base_url . 'google/2.png'; ?> "></a></td> <td><a class="span4 thumbnail" href="<?php echo $assets_setup_base_url . 'google/3.png'; ?> " target="_blank"><img src="<?php echo $assets_setup_base_url . 'google/3.png'; ?> "></a></td> </table> <?php } ?> <?php if ($provider_id == "Twitter") { ?> <table style="text-align: center;margin-bottom:12px;"> <td><a class="span4 thumbnail" href="<?php echo $assets_setup_base_url . 'twitter/1.png'; ?> " target="_blank"><img src="<?php echo $assets_setup_base_url . 'twitter/1.png'; ?> "></a></td> <td><a class="span4 thumbnail" href="<?php echo $assets_setup_base_url . 'twitter/2.png'; ?> " target="_blank"><img src="<?php echo $assets_setup_base_url . 'twitter/2.png'; ?> "></a></td> <td><a class="span4 thumbnail" href="<?php echo $assets_setup_base_url . 'twitter/3.png'; ?> " target="_blank"><img src="<?php echo $assets_setup_base_url . 'twitter/3.png'; ?> "></a></td> </table> <?php } ?> <?php if ($provider_id == "WordPress") { ?> <table style="text-align: center;margin-bottom:12px;"> <td><a class="span4 thumbnail" href="<?php echo $assets_setup_base_url . 'wordpress/1.png'; ?> " target="_blank"><img src="<?php echo $assets_setup_base_url . 'wordpress/1.png'; ?> "></a></td> <td><a class="span4 thumbnail" href="<?php echo $assets_setup_base_url . 'wordpress/2.png'; ?> " target="_blank"><img src="<?php echo $assets_setup_base_url . 'wordpress/2.png'; ?> "></a></td> <td><a class="span4 thumbnail" href="<?php echo $assets_setup_base_url . 'wordpress/3.png'; ?> " target="_blank"><img src="<?php echo $assets_setup_base_url . 'wordpress/3.png'; ?> "></a></td> </table> <?php } ?> </div> <?php if ($provider_new_app_link) { ?> <hr /> <p> <b><?php _wsl_e("And that's it!", 'wordpress-social-login'); ?> </b> <br /> <?php echo sprintf(_wsl__('If for some reason you still can\'t manage to create an application for %s, first try to <a href="https://www.google.com/search?q=%s API create application" target="_blank">Google it</a>, then check it on <a href="http://www.youtube.com/results?search_query=%s API create application " target="_blank">Youtube</a>, and if nothing works <a href="options-general.php?page=wordpress-social-login&wslp=help">ask for support</a>', 'wordpress-social-login'), $provider_name, $provider_name, $provider_name); ?> . </p> <?php } ?> </div> </div> </div> <?php } ?> <input type="submit" class="button-primary" value="<?php _wsl_e("Save Settings", 'wordpress-social-login'); ?> " /> <?php // HOOKABLE: do_action("wsl_component_networks_setup_end"); }
function wsl_component_networks_setup() { // HOOKABLE: do_action("wsl_component_networks_setup_start"); global $wpdb; global $WORDPRESS_SOCIAL_LOGIN_PROVIDERS_CONFIG; if (isset($_REQUEST["enable"]) && $_REQUEST["enable"]) { $provider_id = $_REQUEST["enable"]; update_option('wsl_settings_' . $provider_id . '_enabled', 1); } ?> <script> function toggleproviderkeys(idp){ if(typeof jQuery=="undefined"){ alert( "Error: WordPress Social Login require jQuery to be installed on your wordpress in order to work!" ); return; } if(jQuery('#wsl_settings_' + idp + '_enabled').val()==1){ jQuery('.wsl_tr_settings_' + idp).show(); } else{ jQuery('.wsl_tr_settings_' + idp).hide(); jQuery('.wsl_div_settings_help_' + idp).hide(); } return false; } function toggleproviderhelp(idp){ if(typeof jQuery=="undefined"){ alert( "Error: WordPress Social Login require jQuery to be installed on your wordpress in order to work!" ); return false; } jQuery('.wsl_div_settings_help_' + idp).show(); return false; } </script> <?php $nbprovider = 0; $assets_base_url = WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL . '/assets/img/16x16/'; foreach ($WORDPRESS_SOCIAL_LOGIN_PROVIDERS_CONFIG as $item) { $provider_id = @$item["provider_id"]; $provider_name = @$item["provider_name"]; $require_client_id = @$item["require_client_id"]; $provide_email = @$item["provide_email"]; $provider_new_app_link = @$item["new_app_link"]; $provider_userguide_section = @$item["userguide_section"]; $provider_callback_url = ""; if (!(isset($item["default_network"]) && $item["default_network"] || get_option('wsl_settings_' . $provider_id . '_enabled'))) { continue; } // default endpoint_url $endpoint_url = WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL; // overwrite endpoint_url if need'd if (get_option('wsl_settings_base_url')) { $endpoint_url = strtolower(get_option('wsl_settings_base_url') . '/hybridauth/'); } if (isset($item["callback"]) && $item["callback"]) { $provider_callback_url = '<span style="color:green">' . $endpoint_url . '?hauth.done=' . $provider_id . '</span>'; } $setupsteps = 0; ?> <a name="setup<?php echo strtolower($provider_id); ?> "></a> <div class="stuffbox" id="namediv"> <h3> <label for="name" class="wp-neworks-label"> <img alt="<?php echo $provider_name; ?> " title="<?php echo $provider_name; ?> " src="<?php echo $assets_base_url . strtolower($provider_id) . '.png'; ?> " style="vertical-align: top;width:16px;height:16px;" /> <?php echo $provider_name; ?> </label> </h3> <div class="inside"> <table class="form-table editcomment"> <tbody> <tr> <td style="width:110px"><?php _wsl_e("Enabled", 'wordpress-social-login'); ?> :</td> <td> <select name="<?php echo 'wsl_settings_' . $provider_id . '_enabled'; ?> " id="<?php echo 'wsl_settings_' . $provider_id . '_enabled'; ?> " onChange="toggleproviderkeys('<?php echo $provider_id; ?> ')" > <option value="1" <?php if (get_option('wsl_settings_' . $provider_id . '_enabled')) { echo "selected"; } ?> >Yes</option> <option value="0" <?php if (!get_option('wsl_settings_' . $provider_id . '_enabled')) { echo "selected"; } ?> >No</option> </select> </td> <td style="width:140px"> </td> </tr> <?php if ($provider_new_app_link) { ?> <?php if ($require_client_id) { // key or id ? ?> <tr valign="top" <?php if (!get_option('wsl_settings_' . $provider_id . '_enabled')) { echo 'style="display:none"'; } ?> class="wsl_tr_settings_<?php echo $provider_id; ?> " > <td><?php _wsl_e("Application ID", 'wordpress-social-login'); ?> :</td> <td><input type="text" name="<?php echo 'wsl_settings_' . $provider_id . '_app_id'; ?> " value="<?php echo get_option('wsl_settings_' . $provider_id . '_app_id'); ?> " ></td> <td><a href="javascript:void(0)" onClick="toggleproviderhelp('<?php echo $provider_id; ?> ')"><?php _wsl_e("Where do I get this info?", 'wordpress-social-login'); ?> </a></td> </tr> <?php } else { ?> <tr valign="top" <?php if (!get_option('wsl_settings_' . $provider_id . '_enabled')) { echo 'style="display:none"'; } ?> class="wsl_tr_settings_<?php echo $provider_id; ?> " > <td><?php _wsl_e("Application Key", 'wordpress-social-login'); ?> :</td> <td><input type="text" name="<?php echo 'wsl_settings_' . $provider_id . '_app_key'; ?> " value="<?php echo get_option('wsl_settings_' . $provider_id . '_app_key'); ?> " ></td> <td><a href="javascript:void(0)" onClick="toggleproviderhelp('<?php echo $provider_id; ?> ')"><?php _wsl_e("Where do I get this info?", 'wordpress-social-login'); ?> </a></td> </tr> <?php } ?> <tr valign="top" <?php if (!get_option('wsl_settings_' . $provider_id . '_enabled')) { echo 'style="display:none"'; } ?> class="wsl_tr_settings_<?php echo $provider_id; ?> " > <td><?php _wsl_e("Application Secret", 'wordpress-social-login'); ?> :</td> <td><input type="text" name="<?php echo 'wsl_settings_' . $provider_id . '_app_secret'; ?> " value="<?php echo get_option('wsl_settings_' . $provider_id . '_app_secret'); ?> " ></td> <td><a href="javascript:void(0)" onClick="toggleproviderhelp('<?php echo $provider_id; ?> ')"><?php _wsl_e("Where do I get this info?", 'wordpress-social-login'); ?> </a></td> </tr> <?php } // if require registration ?> </tbody> </table> <?php if (in_array($provider_id, array("Twitter", "Identica", "Tumblr", "Goodreads", "500px", "Vkontakte", "Gowalla", "Steam"))) { ?> <br /> <hr /> <p style="margin-left:12px;margin-bottom:0px;"> <b style="color:#CB4B16;"><?php _wsl_e("Note", 'wordpress-social-login'); ?> :</b> <?php echo sprintf(_wsl__("<b>%s</b> do not provide their user's email address and by default a random email will then be generated for them instead", 'wordpress-social-login'), $provider_name); ?> . <?php _wsl_e('To change this behaviour and to force new registered users to provide their emails before they get in, goto <b><a href="options-general.php?page=wordpress-social-login&wslp=bouncer">Bouncer</a></b> and enable <b>Profile Completion</b>', 'wordpress-social-login'); ?> . </p> <?php } ?> <br /> <div class="wsl_div_settings_help_<?php echo $provider_id; ?> " style="<?php if (isset($_REQUEST["enable"]) && !isset($_REQUEST["settings-updated"]) && $_REQUEST["enable"] == $provider_id) { echo "-"; } // <= lolz ?> display:none;" > <hr class="wsl" /> <?php if ($provider_new_app_link) { ?> <?php _wsl_e('<span style="color:#CB4B16;">Application</span> id and secret (also sometimes referred as <span style="color:#CB4B16;">Customer</span> key and secret or <span style="color:#CB4B16;">Client</span> id and secret) are what we call an application credentials', 'wordpress-social-login'); ?> . <?php echo sprintf(_wsl__('This application will link your website <code>%s</code> to <code>%s API</code> and these credentials are needed in order for <b>%s</b> users to access your website', 'wordpress-social-login'), $_SERVER["SERVER_NAME"], $provider_name, $provider_name); ?> . <br /> <?php _wsl_e("These credentials may also differ in format, name and content depending on the social network.", 'wordpress-social-login'); ?> <br /> <br /> <?php echo sprintf(_wsl__('To enable authentication with this provider and to register a new <b>%s API Application</b>, carefully follow the steps', 'wordpress-social-login'), $provider_name); ?> :<br /> <?php } else { ?> <p><?php echo sprintf(_wsl__('<b>Done.</b> Nothing more required for <b>%s</b>', 'wordpress-social-login'), $provider_name); ?> .</p> <?php } ?> <div class="wsl_div_settings_help_<?php echo $provider_id; ?> " style="margin-left:40px;"> <?php if ($provider_new_app_link) { ?> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> Go to <a href="<?php echo $provider_new_app_link; ?> " target ="_blanck"><?php echo $provider_new_app_link; ?> </a> and <b>create a new application</b>.</p> <?php if ($provider_id == "Google") { ?> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> On the <b>Dashboard sidebar</b> click on <b>API Access</b> then Click <em style="color:#CB4B16;">"Create an OAuth 2.0 client ID..."</em>.</p> <?php } ?> <?php if ($provider_id == "Google") { ?> </p> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> On the <b>"Create Client ID"</b> popup : <br /> - Enter a product name (the name of your website will do). <br /> - Enter the URL for a logo if you like. <br /> - Click Next. <br /> - Select <em style="color:#CB4B16;">"Web application"</em> as the application type. <br /> - Then switch to advanced settings by clicking on <b>(more options)</b> .</p> <?php } else { ?> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> Fill out any required fields such as the application name and description.</p> <?php } ?> <?php if ($provider_callback_url) { ?> <p> <?php echo "<b>" . ++$setupsteps . "</b>."; ?> Provide this URL as the <b>Callback URL</b> for your application: <br /> <?php echo $provider_callback_url; ?> </p> <?php } ?> <?php if ($provider_id == "MySpace") { ?> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> Put your website domain in the <b>External Url</b> and <b>External Callback Validation</b> fields. This should match with the current hostname <em style="color:#CB4B16;"><?php echo $_SERVER["SERVER_NAME"]; ?> </em>.</p> <?php } ?> <?php if ($provider_id == "Live") { ?> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> Put your website domain in the <b>Redirect Domain</b> field. This should match with the current hostname <em style="color:#CB4B16;"><?php echo $_SERVER["SERVER_NAME"]; ?> </em>.</p> <?php } ?> <?php if ($provider_id == "Facebook") { ?> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> Put your website domain in the <b>Site Url</b> field. This should match with the current hostname <em style="color:#CB4B16;"><?php echo $_SERVER["SERVER_NAME"]; ?> </em>.</p> <?php } ?> <?php if ($provider_id == "LinkedIn") { ?> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> Put your website domain in the <b>Integration URL</b> field. This should match with the current hostname <em style="color:#CB4B16;"><?php echo $_SERVER["SERVER_NAME"]; ?> </em>.</p> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> Set the <b>Application Type</b> to <em style="color:#CB4B16;">Web Application</em>.</p> <?php } ?> <?php if ($provider_id == "Twitter") { ?> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> Put your website domain in the <b>Application Website</b> and <b>Application Callback URL</b> fields. This should match with the current hostname <em style="color:#CB4B16;"><?php echo $_SERVER["SERVER_NAME"]; ?> </em>.</p> <?php } ?> <p><?php echo "<b>" . ++$setupsteps . "</b>."; ?> Once you have registered, copy and past the created application credentials into this setup page.</p> <?php } ?> <?php if ($provider_id == "Facebook") { ?> <hr /> <table style="text-align: center;margin-bottom:12px;"> <td><a class="span4 thumbnail" href="http://hybridauth.sf.net/userguide/img/setup/facebook/1.png" target="_blank"><img src="http://hybridauth.sf.net/userguide/img/setup/facebook/1.png"></a></td> <td><a class="span4 thumbnail" href="http://hybridauth.sf.net/userguide/img/setup/facebook/2.png" target="_blank"><img src="http://hybridauth.sf.net/userguide/img/setup/facebook/2.png"></a></td> <td><a class="span4 thumbnail" href="http://hybridauth.sf.net/userguide/img/setup/facebook/3.png" target="_blank"><img src="http://hybridauth.sf.net/userguide/img/setup/facebook/3.png"></a></td> </table> <hr /> <?php } ?> <?php if ($provider_id == "Google") { ?> <hr /> <table style="text-align: center;margin-bottom:12px;"> <td><a class="span4 thumbnail" href="http://hybridauth.sf.net/userguide/img/setup/google/1.png" target="_blank"><img src="http://hybridauth.sf.net/userguide/img/setup/google/1.png"></a></td> <td><a class="span4 thumbnail" href="http://hybridauth.sf.net/userguide/img/setup/google/2.png" target="_blank"><img src="http://hybridauth.sf.net/userguide/img/setup/google/2.png"></a></td> <td><a class="span4 thumbnail" href="http://hybridauth.sf.net/userguide/img/setup/google/3.png" target="_blank"><img src="http://hybridauth.sf.net/userguide/img/setup/google/3.png"></a></td> </table> <hr /> <?php } ?> <?php if ($provider_id == "Twitter") { ?> <hr /> <table style="text-align: center;margin-bottom:12px;"> <td><a class="span4 thumbnail" href="http://hybridauth.sf.net/userguide/img/setup/twitter/1.png" target="_blank"><img src="http://hybridauth.sf.net/userguide/img/setup/twitter/1.png"></a></td> <td><a class="span4 thumbnail" href="http://hybridauth.sf.net/userguide/img/setup/twitter/2.png" target="_blank"><img src="http://hybridauth.sf.net/userguide/img/setup/twitter/2.png"></a></td> <td><a class="span4 thumbnail" href="http://hybridauth.sf.net/userguide/img/setup/twitter/3.png" target="_blank"><img src="http://hybridauth.sf.net/userguide/img/setup/twitter/3.png"></a></td> </table> <hr /> <?php } ?> <?php if ($provider_new_app_link) { ?> <p> <b><?php _wsl_e("And that's it!", 'wordpress-social-login'); ?> </b> <br /> <?php echo sprintf(_wsl__('If for some reason you still can\'t figure it out, first try to a) <a class="button-primary" href="https://www.google.com/search?q=%s API create application" target="_blank">Google it</a>, then check it on b) <a class="button-primary" href="http://www.youtube.com/results?search_query=%s API create application " target="_blank">Youtube</a> and if nothing works c) <a class="button-primary" href="options-general.php?page=wordpress-social-login&wslp=help">ask for support</a>', 'wordpress-social-login'), $provider_name, $provider_name); ?> . </p> <?php } ?> </div> </div> </div> </div> <?php } ?> <input type="submit" class="button-primary" value="<?php _wsl_e("Save Settings", 'wordpress-social-login'); ?> " /> <?php // HOOKABLE: do_action("wsl_component_networks_setup_end"); }
function wsl_component_components_setup() { // HOOKABLE: do_action("wsl_component_components_setup_start"); global $WORDPRESS_SOCIAL_LOGIN_COMPONENTS; ?> <div style="padding: 15px; margin-bottom: 8px; border: 1px solid #ddd; background-color: #fff;box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);"> <?php _wsl_e("By default, only the three WSL core components are enabled. You can selectively enable or disable any of the non-core components by using the form below. Your WSL installation will continue to function. However, the features of the disabled components will no longer be accessible", 'wordpress-social-login'); ?> . </div> <form action="" method="post"> <table class="widefat fixed plugins" cellspacing="0"> <thead> <tr> <th scope="col" class="manage-column column-label" style="width: 190px;"><?php _wsl_e("Component", 'wordpress-social-login'); ?> </th> <th scope="col" class="manage-column column-description"><?php _wsl_e("Description", 'wordpress-social-login'); ?> </th> <th scope="col" class="manage-column column-action" style="width: 140px;"> </th> </tr> </thead> <tfoot> <tr> <th scope="col" class="manage-column column-label" style="width: 190px;"><?php _wsl_e("Component", 'wordpress-social-login'); ?> </th> <th scope="col" class="manage-column column-description"><?php _wsl_e("Description", 'wordpress-social-login'); ?> </th> <th scope="col" class="manage-column column-action" style="width: 140px;"> </th> </tr> </tfoot> <tbody id="the-list"> <?php foreach ($WORDPRESS_SOCIAL_LOGIN_COMPONENTS as $name => $settings) { $plugin_tr_class = ''; $plugin_notices = ''; $plugin_enablable = true; if ($name == "core") { continue; } $plugin_tr_class = $settings["enabled"] ? "active" : "inactive"; ?> <tr id="<?php echo $name; ?> " class="<?php echo $name; ?> <?php echo $plugin_tr_class; ?> "> <td class="component-label" style="width: 190px;"> <?php if ($settings["type"] == "core") { ?> <div class="icon16 icon-generic"></div> <?php } elseif ($settings["type"] == "addon") { ?> <div class="icon16 icon-plugins"></div> <?php } else { ?> <div class="icon16 icon-appearance"></div> <?php } ?> <strong><?php _wsl_e($settings["label"], 'wordpress-social-login'); ?> </strong> </td> <td class="column-description"> <p><?php _wsl_e($settings["description"], 'wordpress-social-login'); ?> </p> <?php $meta = array(); if (isset($settings["version"])) { $meta[] = sprintf(_wsl__("Version %s", 'wordpress-social-login'), $settings["version"]); } if (isset($settings["author"])) { if (isset($settings["author_url"])) { $meta[] = sprintf(_wsl__('By <a href="%s" target="_blank">%s</a>', 'wordpress-social-login'), $settings["author_url"], $settings["author"]); } else { $meta[] = sprintf(_wsl__('By %s', 'wordpress-social-login'), $settings["author"]); } } if (isset($settings["component_url"])) { $meta[] = sprintf(_wsl__('<a href="%s" target="_blank">Visit component site</a>', 'wordpress-social-login'), $settings["component_url"]); } if ($meta) { ?> <p><?php echo implode(' | ', $meta); ?> </p><?php } ?> </td> <td class="column-action" align="right" style="width: 120px;"> <p> <?php if ($plugin_enablable && $settings["type"] != "core") { ?> <?php if ($settings["enabled"]) { ?> <a class="button-secondary" href="options-general.php?page=wordpress-social-login&wslp=components&disable=<?php echo $name; ?> "><?php _wsl_e("Disable", 'wordpress-social-login'); ?> </a> <?php } else { ?> <a class="button-primary" style="color:#ffffff" href="options-general.php?page=wordpress-social-login&wslp=components&enable=<?php echo $name; ?> "><?php _wsl_e("Enable", 'wordpress-social-login'); ?> </a> <?php } ?> <?php } ?> </p> </td> </tr> <?php } ?> </tbody> </table> </form> <?php // HOOKABLE: do_action("wsl_component_components_setup_end"); }
/** * Generate content for the added column to wp-admin/users.php */ function wsl_manage_users_custom_column($value, $column_name, $user_id) { if ('wsl_column' != $column_name) { return $value; } $tmp = wsl_get_user_by_meta_key_and_user_id("wsl_user_image", $user_id); if (!$tmp) { return ""; } return '<a href="options-general.php?page=wordpress-social-login&wslp=users&uid=' . $user_id . '">' . _wsl__("Profile", 'wordpress-social-login') . '</a> | <a href="options-general.php?page=wordpress-social-login&wslp=contacts&uid=' . $user_id . '">' . _wsl__("Contacts", 'wordpress-social-login') . '</a>'; }
function wsl_component_contacts_list($user_id) { // HOOKABLE: do_action("wsl_component_contacts_list_start"); $assets_base_url = WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL . '/assets/img/16x16/'; $user_data = get_userdata($user_id); if (!$user_data) { ?> <div style="padding: 15px; margin-bottom: 8px; border: 1px solid #ddd; background-color: #fff;box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);"> <?php _wsl_e("WordPress user not found!", 'wordpress-social-login'); ?> . </div> <?php return; } add_thickbox(); $pagenum = isset($_GET['pagenum']) ? absint($_GET['pagenum']) : 1; $limit = 50; // number of rows in page $offset = ($pagenum - 1) * $limit; $num_of_pages = 0; $total = wsl_get_stored_hybridauth_user_contacts_count_by_user_id($user_id); $num_of_pages = ceil($total / $limit); $user_contacts = wsl_get_stored_hybridauth_user_contacts_by_user_id($user_id, $offset, $limit); $actions = array('edit_details' => '<a class="button button-secondary thickbox" href="' . admin_url('user-edit.php?user_id=' . $user_id . '&TB_iframe=true&width=1150&height=550') . '">' . _wsl__('Edit user details', 'wordpress-social-login') . '</a>', 'show_profiles' => '<a class="button button-secondary" href="' . admin_url('options-general.php?page=wordpress-social-login&wslp=users&uid=' . $user_id) . '">' . _wsl__('Show user social profiles', 'wordpress-social-login') . '</a>'); // HOOKABLE: $actions = apply_filters('wsl_component_users_profile_alter_actions_list', $actions, $user_id); ?> <div style="padding: 15px; margin-bottom: 8px; border: 1px solid #ddd; background-color: #fff;box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);"> <h3 style="margin:0;"><?php echo sprintf(_wsl__("%s's contacts list", 'wordpress-social-login'), $user_data->display_name); ?> </h3> <p style="float: <?php if (is_rtl()) { echo 'left'; } else { echo 'right'; } ?> ;margin-top:-23px"> <?php echo implode(' ', $actions); ?> </p> </div> <style> .widefatop td, .widefatop th { border: 1px solid #DDDDDD; } .widefatop th label { font-weight: bold; } </style> <table cellspacing="0" class="wp-list-table widefat fixed users"> <thead> <tr> <th width="100"><span><?php _wsl_e("Provider", 'wordpress-social-login'); ?> </span></th> <th><span><?php _wsl_e("Contact Name", 'wordpress-social-login'); ?> </span></th> <th><span><?php _wsl_e("Contact Email", 'wordpress-social-login'); ?> </span></th> <th><span><?php _wsl_e("Contact Profile Url", 'wordpress-social-login'); ?> </span></th> </tr> </thead> <tfoot> <tr> <th width="100"><span><?php _wsl_e("Provider", 'wordpress-social-login'); ?> </span></th> <th><span><?php _wsl_e("Contact Name", 'wordpress-social-login'); ?> </span></th> <th><span><?php _wsl_e("Contact Email", 'wordpress-social-login'); ?> </span></th> <th><span><?php _wsl_e("Contact Profile Url", 'wordpress-social-login'); ?> </span></th> </tr> </tfoot> <tbody id="the-list"> <?php $i = 0; // have contacts? if (!$user_contacts) { ?> <tr class="no-items"><td colspan="4" class="colspanchange"><?php _wsl_e("No contacts found", 'wordpress-social-login'); ?> .</td></tr> <?php } else { foreach ($user_contacts as $item) { ?> <tr class="<?php if (++$i % 2) { echo "alternate"; } ?> "> <td nowrap> <img src="<?php echo $assets_base_url . strtolower($item->provider) . '.png'; ?> " style="vertical-align:top;width:16px;height:16px;" /> <?php _wsl_e($item->provider, 'wordpress-social-login'); ?> </td> <td> <?php if ($item->photo_url) { ?> <img width="32" height="32" class="avatar avatar-32 photo" align="middle" src="<?php echo $item->photo_url; ?> " > <?php } else { ?> <img width="32" height="32" class="avatar avatar-32 photo" align="middle" src="http://www.gravatar.com/avatar/<?php echo md5(strtolower(trim($item->email))); ?> " > <?php } ?> <strong><?php echo $item->full_name ? $item->full_name : '-'; ?> </strong> </td> <td> <?php if ($item->email) { ?> <a href="mailto:<?php echo $item->email; ?> "><?php echo $item->email; ?> </a> <?php } else { ?> - <?php } ?> </td> <td> <?php if ($item->profile_url) { ?> <a href="<?php echo $item->profile_url; ?> " target="_blank"><?php echo str_ireplace(array("http://www.", "https://www.", "http://", "https://"), array('', '', '', '', ''), $item->profile_url); ?> </a> <?php } else { ?> - <?php } ?> </td> </tr> <?php } } ?> </tbody> </table> <?php $page_links = paginate_links(array('base' => add_query_arg('pagenum', '%#%'), 'format' => '', 'prev_text' => __('«', 'text-domain'), 'next_text' => __('»', 'text-domain'), 'total' => $num_of_pages, 'current' => $pagenum)); if ($page_links) { echo '<div class="tablenav"><div class="tablenav-pages" style="margin: 1em 0">' . $page_links . '</div></div>'; } // HOOKABLE: do_action("wsl_component_contacts_list_end"); }
function wsl_process_login_create_wp_user($provider, $hybridauth_user_profile, $request_user_login, $request_user_email) { // HOOKABLE: any action to fire right before a user created on database do_action('wsl_hook_process_login_before_create_wp_user'); $user_login = null; $user_email = null; // if coming from "complete registration form" if ($request_user_email && $request_user_login) { $user_login = $request_user_login; $user_email = $request_user_email; } else { // generate a valid user login $user_login = trim(str_replace(' ', '_', strtolower($hybridauth_user_profile->displayName))); $user_email = $hybridauth_user_profile->email; if (empty($user_login)) { $user_login = trim($hybridauth_user_profile->lastName . " " . $hybridauth_user_profile->firstName); } if (empty($user_login)) { $user_login = strtolower($provider) . "_user_" . md5($hybridauth_user_profile->identifier); } // user name should be unique if (username_exists($user_login)) { $i = 1; $user_login_tmp = $user_login; do { $user_login_tmp = $user_login . "_" . $i++; } while (username_exists($user_login_tmp)); $user_login = $user_login_tmp; } // generate an email if none if (!isset($user_email) or !is_email($user_email)) { $user_email = strtolower($provider . "_user_" . $user_login) . "@example.com"; } // email should be unique if (email_exists($user_email)) { do { $user_email = md5(uniqid(wp_rand(10000, 99000))) . "@example.com"; } while (email_exists($user_email)); } $user_login = sanitize_user($user_login, true); if (!validate_username($user_login)) { $user_login = strtolower($provider) . "_user_" . md5($hybridauth_user_profile->identifier); } } $display_name = $hybridauth_user_profile->displayName; if ($request_user_login || empty($display_name)) { $display_name = $user_login; } $userdata = array('user_login' => $user_login, 'user_email' => $user_email, 'display_name' => $display_name, 'first_name' => $hybridauth_user_profile->firstName, 'last_name' => $hybridauth_user_profile->lastName, 'user_url' => $hybridauth_user_profile->profileURL, 'description' => $hybridauth_user_profile->description, 'user_pass' => wp_generate_password()); // Bouncer :: Membership level if (get_option('wsl_settings_bouncer_new_users_membership_default_role') != "default") { $userdata['role'] = get_option('wsl_settings_bouncer_new_users_membership_default_role'); } // Bouncer :: User Moderation : None if (get_option('wsl_settings_bouncer_new_users_moderation_level') == 1) { // well do nothing.. } // Bouncer :: User Moderation : Yield to Theme My Login plugin if (get_option('wsl_settings_bouncer_new_users_moderation_level') > 100) { $userdata['role'] = "pending"; } // HOOKABLE: change the user data if (apply_filters('wsl_hook_process_login_alter_userdata', $userdata, $provider, $hybridauth_user_profile)) { $userdata = apply_filters('wsl_hook_process_login_alter_userdata', $userdata, $provider, $hybridauth_user_profile); } // HOOKABLE: any action to fire right before a user created on database do_action('wsl_hook_process_login_before_insert_user', $userdata, $provider, $hybridauth_user_profile); // HOOKABLE: delegate user insert to a custom function $user_id = apply_filters('wsl_hook_process_login_alter_insert_user', $userdata, $provider, $hybridauth_user_profile); // Create a new user if (!$user_id || !is_integer($user_id)) { $user_id = wp_insert_user($userdata); } // update user metadata if ($user_id && is_integer($user_id)) { update_user_meta($user_id, $provider, $hybridauth_user_profile->identifier); } else { if (is_wp_error($user_id)) { echo $user_id->get_error_message(); } else { return wsl_render_notices_pages(_wsl__("An error occurred while creating a new user!", 'wordpress-social-login')); } } // Send notifications if (get_option('wsl_settings_users_notification') == 1) { wsl_admin_notification($user_id, $provider); } // HOOKABLE: any action to fire right after a user created on database do_action('wsl_hook_process_login_after_create_wp_user', $user_id, $provider, $hybridauth_user_profile); return array($user_id, $user_login, $user_email); }
/** * Renders wsl admin welcome panel */ function wsl_admin_welcome_panel() { if (isset($_REQUEST["wsldwp"]) && (int) $_REQUEST["wsldwp"]) { $wsldwp = (int) $_REQUEST["wsldwp"]; update_option("wsl_settings_welcome_panel_enabled", wsl_get_version()); return; } // if new user or wsl updated, then we display wsl welcome panel if (get_option('wsl_settings_welcome_panel_enabled') == wsl_get_version()) { return; } $wslp = "networks"; if (isset($_REQUEST["wslp"])) { $wslp = $_REQUEST["wslp"]; } ?> <!-- if you want to know if a UI was made by developer, then here is a tip: he will always use tables //> wsl-w-panel is shamelessly borrowed and modified from wordpress welcome-panel --> <div id="wsl-w-panel"> <a href="options-general.php?page=wordpress-social-login&wslp=<?php echo $wslp; ?> &wsldwp=1" id="wsl-w-panel-dismiss" <?php if (is_rtl()) { echo 'style="left: 10px;right: auto;"'; } ?> ><?php _wsl_e("Dismiss", 'wordpress-social-login'); ?> </a> <table width="100%" border="0" style="margin:0;padding:0;"> <tr> <td width="10" valign="top"></td> <td width="300" valign="top"> <b style="font-size: 16px;"><?php _wsl_e("Welcome!", 'wordpress-social-login'); ?> </b> <p> <?php _wsl_e("If you are still new to WordPress Social Login, we have provided a few walkthroughs to get you started", 'wordpress-social-login'); ?> . </p> </td> <td width="40" valign="top"></td> <td width="260" valign="top"> <br /> <p> <b><?php _wsl_e("Get Started", 'wordpress-social-login'); ?> </b> </p> <ul style="margin-left:25px;"> <li><a href="http://miled.github.io/wordpress-social-login/overview.html" target="_blank"><?php _wsl_e('Plugin Overview', 'wordpress-social-login'); ?> </a></li> <li><a href="http://miled.github.io/wordpress-social-login/networks.html" target="_blank"><?php _wsl_e('Setup and Configuration', 'wordpress-social-login'); ?> </a></li> <li><a href="http://miled.github.io/wordpress-social-login/widget.html" target="_blank"><?php _wsl_e('Customize WSL Widgets', 'wordpress-social-login'); ?> </a></li> <li><a href="http://miled.github.io/wordpress-social-login/userdata.html" target="_blank"><?php _wsl_e('Manage users and contacts', 'wordpress-social-login'); ?> </a></li> <li><a href="http://miled.github.io/wordpress-social-login/documentation.html" target="_blank"><?php _wsl_e('WSL Developer API', 'wordpress-social-login'); ?> </a></li> </ul> </td> <td width="" valign="top"> <br /> <p> <b><?php echo sprintf(_wsl__("What's new on WSL %s", 'wordpress-social-login'), wsl_get_version()); ?> </b> </p> <ul style="margin-left:25px;"> <li><?php _wsl_e('WSL now support authentications through <a href="https://dribbble.com" target="_blank">Dribbble.com</a>. Hooray for fellow designers', 'wordpress-social-login'); ?> !</li> <li><?php _wsl_e('<a href="http://store.steampowered.com/" target="_blank">Steam</a> provider has been entirely reworked and now fully support the new Web API', 'wordpress-social-login'); ?> .</li> <li><?php _wsl_e('WSL admin interfaces have been reworked and can be now extended with hooks', 'wordpress-social-login'); ?> .</li> <li><?php _wsl_e('Profile completion form has received a visual update', 'wordpress-social-login'); ?> .</li> <li><?php _wsl_e('Bouncer Membership level can be now set to any user role', 'wordpress-social-login'); ?> .</li> <li><?php _wsl_e('WSL now provide an <a href="http://miled.github.io/wordpress-social-login/developer-api-apis.html" target="_blank">easier access</a> to social networks apis', 'wordpress-social-login'); ?> .</li> <li><?php _wsl_e('Fix several stability issues', 'wordpress-social-login'); ?> .</li> </ul> </td> </tr> <tr id="wsl-w-panel-updates-tr"> <td colspan="5" style="border-top:1px solid #ccc;" id="wsl-w-panel-updates-td"> </td> </tr> </table> </div> <?php }
function wsl_component_components_gallery() { return; // ya men 3ach // HOOKABLE: do_action("wsl_component_components_gallery_start"); $response = wp_remote_get('http://miled.github.io/wordpress-social-login/components-' . wsl_get_version() . '.json', array('timeout' => 15, 'sslverify' => false)); if (!is_wp_error($response)) { $response = wp_remote_retrieve_body($response); $components = json_decode($response); if ($components) { ?> <br /> <h2><?php _wsl_e("Other Components available", 'wordpress-social-login'); ?> </h2> <p><?php _wsl_e("These components and add-ons can extend the functionality of WordPress Social Login", 'wordpress-social-login'); ?> .</p> <?php foreach ($components as $item) { $item = (array) $item; ?> <div class="wsl_component_div"> <h3 style="margin:0px;"><?php _wsl_e($item['name'], 'wordpress-social-login'); ?> </h3> <div class="wsl_component_about_div"> <p> <?php _wsl_e($item['description'], 'wordpress-social-login'); ?> <br /> <?php echo sprintf(_wsl__('<em>By <a href="%s">%s</a></em>', 'wordpress-social-login'), $item['developer_link'], $item['developer_name']); ?> </p> </div> <a class="button button-secondary" href="<?php echo $item['download_link']; ?> " target="_blank"><?php _wsl_e("Get this Component", 'wordpress-social-login'); ?> </a> </div> <?php } ?> <div class="wsl_component_div"> <h3 style="margin:0px;"><?php _wsl_e("Build yours", 'wordpress-social-login'); ?> </h3> <div class="wsl_component_about_div"> <p><?php _wsl_e("Want to build your own custom <b>WordPress Social Login</b> component? It's pretty easy. Just refer to the online developer documentation.", 'wordpress-social-login'); ?> </p> </div> <a class="button button-primary" href="http://miled.github.io/wordpress-social-login/documentation.html" target="_blank"><?php _wsl_e("WSL Developer API", 'wordpress-social-login'); ?> </a> <a class="button button-secondary" href="http://miled.github.io/wordpress-social-login/submit-component.html" target="_blank"><?php _wsl_e("Submit your WSL Component", 'wordpress-social-login'); ?> </a> </div> <?php } } // HOOKABLE: do_action("wsl_component_components_gallery_end"); }
/** * Check and upgrade compatibilities from old WSL versions * * Here we attempt to: * - set to default all settings when WSL is installed * - make wsl compatible when updating from old versions by registring any option * * Side note: the things here are not optimal and the list is kind of long. If you have any * better idea on how to tackle this issue, please don't hesitate to share it! */ function wsl_check_compatibilities() { # widget settings / customize if (!get_option('wsl_settings_redirect_url')) { update_option('wsl_settings_redirect_url', site_url()); } if (!get_option('wsl_settings_connect_with_label')) { update_option('wsl_settings_connect_with_label', "Connect with:"); } if (!get_option('wsl_settings_use_popup')) { update_option('wsl_settings_use_popup', 2); } if (!get_option('wsl_settings_widget_display')) { update_option('wsl_settings_widget_display', 1); } if (!get_option('wsl_settings_authentication_widget_css')) { update_option('wsl_settings_authentication_widget_css', "#wp-social-login-connect-with {font-weight: bold;}\n#wp-social-login-connect-options {padding:10px;}\n#wp-social-login-connect-options a {text-decoration: none;}\n#wp-social-login-connect-options img {border:0 none;}\n.wsl_connect_with_provider {}"); } # bouncer if (!get_option('wsl_settings_bouncer_registration_enabled')) { update_option('wsl_settings_bouncer_registration_enabled', 1); } if (!get_option('wsl_settings_bouncer_authentication_enabled')) { update_option('wsl_settings_bouncer_authentication_enabled', 1); } if (!get_option('wsl_settings_bouncer_linking_accounts_enabled')) { update_option('wsl_settings_bouncer_linking_accounts_enabled', 2); } if (get_option('wsl_settings_bouncer_email_validation_enabled') == 1) { update_option('wsl_settings_bouncer_profile_completion_require_email', 1); delete_option('wsl_settings_bouncer_email_validation_enabled'); delete_option('wsl_settings_bouncer_email_validation_text_notice'); delete_option('wsl_settings_bouncer_email_validation_text_submit_button'); delete_option('wsl_settings_bouncer_email_validation_text_email'); delete_option('wsl_settings_bouncer_email_validation_text_username'); delete_option('wsl_settings_bouncer_email_validation_text_email_invalid'); delete_option('wsl_settings_bouncer_email_validation_text_username_invalid'); delete_option('wsl_settings_bouncer_email_validation_text_email_exists'); delete_option('wsl_settings_bouncer_email_validation_text_username_exists'); delete_option('wsl_settings_bouncer_email_validation_text_connected_with'); } if (!get_option('wsl_settings_bouncer_profile_completion_require_email')) { update_option('wsl_settings_bouncer_profile_completion_require_email', 2); } if (!get_option('wsl_settings_bouncer_profile_completion_change_email')) { update_option('wsl_settings_bouncer_profile_completion_change_email', 2); } if (!get_option('wsl_settings_bouncer_profile_completion_change_username')) { update_option('wsl_settings_bouncer_profile_completion_change_username', 2); } if (!get_option('wsl_settings_bouncer_profile_completion_text_notice')) { update_option('wsl_settings_bouncer_profile_completion_text_notice', _wsl__("Almost there, we just need to check a couple of things", 'wordpress-social-login')); } if (!get_option('wsl_settings_bouncer_profile_completion_text_submit_button')) { update_option('wsl_settings_bouncer_profile_completion_text_submit_button', _wsl__("Continue", 'wordpress-social-login')); } if (!get_option('wsl_settings_bouncer_profile_completion_text_email')) { update_option('wsl_settings_bouncer_profile_completion_text_email', _wsl__("E-mail", 'wordpress-social-login')); } if (!get_option('wsl_settings_bouncer_profile_completion_text_username')) { update_option('wsl_settings_bouncer_profile_completion_text_username', _wsl__("Username", 'wordpress-social-login')); } if (!get_option('wsl_settings_bouncer_profile_completion_text_email_invalid')) { update_option('wsl_settings_bouncer_profile_completion_text_email_invalid', _wsl__("E-mail is not valid!", 'wordpress-social-login')); } if (!get_option('wsl_settings_bouncer_profile_completion_text_username_invalid')) { update_option('wsl_settings_bouncer_profile_completion_text_username_invalid', _wsl__("Username is not valid!", 'wordpress-social-login')); } if (!get_option('wsl_settings_bouncer_profile_completion_text_email_exists')) { update_option('wsl_settings_bouncer_profile_completion_text_email_exists', _wsl__("That E-mail is already registered!", 'wordpress-social-login')); } if (!get_option('wsl_settings_bouncer_profile_completion_text_username_exists')) { update_option('wsl_settings_bouncer_profile_completion_text_username_exists', _wsl__("That Username is already registered!", 'wordpress-social-login')); } if (!get_option('wsl_settings_bouncer_profile_completion_text_connected_with')) { update_option('wsl_settings_bouncer_profile_completion_text_connected_with', _wsl__("You are now connected via", 'wordpress-social-login')); } if (!get_option('wsl_settings_bouncer_new_users_moderation_level')) { update_option('wsl_settings_bouncer_new_users_moderation_level', 1); } if (!get_option('wsl_settings_bouncer_new_users_membership_default_role')) { update_option('wsl_settings_bouncer_new_users_membership_default_role', "default"); } if (!get_option('wsl_settings_bouncer_new_users_restrict_domain_enabled')) { update_option('wsl_settings_bouncer_new_users_restrict_domain_enabled', 2); } if (!get_option('wsl_settings_bouncer_new_users_restrict_domain_text_bounce')) { update_option('wsl_settings_bouncer_new_users_restrict_domain_text_bounce', _wsl__("Bouncer says no.", 'wordpress-social-login')); } if (!get_option('wsl_settings_bouncer_new_users_restrict_email_enabled')) { update_option('wsl_settings_bouncer_new_users_restrict_email_enabled', 2); } if (!get_option('wsl_settings_bouncer_new_users_restrict_email_text_bounce')) { update_option('wsl_settings_bouncer_new_users_restrict_email_text_bounce', _wsl__("Bouncer say he refuses.", 'wordpress-social-login')); } if (!get_option('wsl_settings_bouncer_new_users_restrict_profile_enabled')) { update_option('wsl_settings_bouncer_new_users_restrict_profile_enabled', 2); } if (!get_option('wsl_settings_bouncer_new_users_restrict_profile_text_bounce')) { update_option('wsl_settings_bouncer_new_users_restrict_profile_text_bounce', _wsl__("Bouncer say only Mundo can go where he pleases!", 'wordpress-social-login')); } # contacts import if (!get_option('wsl_settings_contacts_import_facebook')) { update_option('wsl_settings_contacts_import_facebook', 2); } if (!get_option('wsl_settings_contacts_import_google')) { update_option('wsl_settings_contacts_import_google', 2); } if (!get_option('wsl_settings_contacts_import_twitter')) { update_option('wsl_settings_contacts_import_twitter', 2); } if (!get_option('wsl_settings_contacts_import_live')) { update_option('wsl_settings_contacts_import_live', 2); } if (!get_option('wsl_settings_contacts_import_linkedin')) { update_option('wsl_settings_contacts_import_linkedin', 2); } // enable default providers global $WORDPRESS_SOCIAL_LOGIN_PROVIDERS_CONFIG; $nok = true; foreach ($WORDPRESS_SOCIAL_LOGIN_PROVIDERS_CONFIG as $item) { $provider_id = $item["provider_id"]; if (get_option('wsl_settings_' . $provider_id . '_enabled')) { $nok = false; } } if ($nok) { foreach ($WORDPRESS_SOCIAL_LOGIN_PROVIDERS_CONFIG as $item) { $provider_id = $item["provider_id"]; if (isset($item["default_network"]) && $item["default_network"]) { update_option('wsl_settings_' . $provider_id . '_enabled', 1); } } } }
/** * Renders wsl admin welcome panel */ function wsl_admin_welcome_panel() { if (isset($_REQUEST["wsldwp"]) && (int) $_REQUEST["wsldwp"]) { $wsldwp = (int) $_REQUEST["wsldwp"]; update_option("wsl_settings_welcome_panel_enabled", wsl_get_version()); return; } // if new user or wsl updated, then we display wsl welcome panel if (get_option('wsl_settings_welcome_panel_enabled') == wsl_get_version()) { return; } $wslp = "networks"; if (isset($_REQUEST["wslp"])) { $wslp = $_REQUEST["wslp"]; } ?> <!-- if you want to know if a UI was made by developer, then here is a tip: he will always use tables //> wsl-w-panel is shamelessly borrowed and modified from wordpress welcome-panel --> <div id="wsl-w-panel"> <a href="options-general.php?page=wordpress-social-login&wslp=<?php echo $wslp; ?> &wsldwp=1" id="wsl-w-panel-dismiss" <?php if (is_rtl()) { echo 'style="left: 10px;right: auto;"'; } ?> ><?php _wsl_e("Dismiss", 'wordpress-social-login'); ?> </a> <table width="100%" border="0" style="margin:0;padding:0;"> <tr> <td width="10" valign="top"></td> <td width="300" valign="top"> <b style="font-size: 16px;"><?php _wsl_e("Welcome!", 'wordpress-social-login'); ?> </b> <p> <?php _wsl_e("If you are still new to WordPress Social Login, we have provided a few walkthroughs to get you started", 'wordpress-social-login'); ?> . </p> </td> <td width="40" valign="top"></td> <td width="260" valign="top"> <br /> <p> <b><?php _wsl_e("Get Started", 'wordpress-social-login'); ?> </b> </p> <ul style="margin-left:25px;"> <li><a href="http://miled.github.io/wordpress-social-login/overview.html" target="_blank"><?php _wsl_e('Plugin Overview', 'wordpress-social-login'); ?> </a></li> <li><a href="http://miled.github.io/wordpress-social-login/networks.html" target="_blank"><?php _wsl_e('Setup and Configuration', 'wordpress-social-login'); ?> </a></li> <li><a href="http://miled.github.io/wordpress-social-login/widget.html" target="_blank"><?php _wsl_e('Customize WSL Widgets', 'wordpress-social-login'); ?> </a></li> <li><a href="http://miled.github.io/wordpress-social-login/userdata.html" target="_blank"><?php _wsl_e('Manage users and contacts', 'wordpress-social-login'); ?> </a></li> <li><a href="http://miled.github.io/wordpress-social-login/documentation.html" target="_blank"><?php _wsl_e('WSL Developer API', 'wordpress-social-login'); ?> </a></li> </ul> </td> <td width="" valign="top"> <br /> <p> <b><?php echo sprintf(_wsl__("What's new on WSL %s", 'wordpress-social-login'), wsl_get_version()); ?> </b> </p> <ul style="margin-left:25px;"> <li><?php _wsl_e('...', 'wordpress-social-login'); ?> </li> </ul> </td> </tr> <tr id="wsl-w-panel-updates-tr"> <td colspan="5" style="border-top:1px solid #ccc;" id="wsl-w-panel-updates-td"> </td> </tr> </table> </div> <?php }
function wsl_component_contacts() { // HOOKABLE: do_action("wsl_component_contacts_start"); global $wpdb; $assets_base_url = WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL . '/assets/img/16x16/'; ?> <div> <?php if (isset($_REQUEST["uid"]) && (int) $_REQUEST["uid"]) { $user_id = (int) $_REQUEST["uid"]; } else { ?> <form method="post" id="wsl_setup_form" action="options.php"> <?php settings_fields('wsl-settings-group-contacts-import'); ?> <div class="metabox-holder columns-2" id="post-body"> <div id="post-body-content"> <div id="namediv" class="stuffbox"> <h3> <label for="name"><?php _wsl_e("Settings", 'wordpress-social-login'); ?> </label> </h3> <div class="inside"> <p> <?php _wsl_e("<b>WordPress Social Login</b> is now introducing <b>Contacts Import</b> as a new feature. When enabled, users authenticating through WordPress Social Login will be asked for the authorisation to import their contact list. Note that some social networks do not provide certains of their users information like contacts emails, photos and or profile urls", 'wordpress-social-login'); ?> . </p> <h4><?php _wsl_e("Enable contacts import for", 'wordpress-social-login'); ?> :</h4> <table width="100%" border="0" cellpadding="5" cellspacing="2" style="border-top:1px solid #ccc;border-bottom:1px solid #ccc"> <tr> <td align="right"><strong>Facebook :</strong></td> <td> <select name="wsl_settings_contacts_import_facebook" <?php if (!get_option('wsl_settings_Facebook_enabled')) { echo "disabled"; } ?> > <option <?php if (get_option('wsl_settings_contacts_import_facebook') == 1) { echo "selected"; } ?> value="1"><?php _wsl_e("Enabled", 'wordpress-social-login'); ?> </option> <option <?php if (get_option('wsl_settings_contacts_import_facebook') == 2) { echo "selected"; } ?> value="2"><?php _wsl_e("Disabled", 'wordpress-social-login'); ?> </option> </select> </td> <td align="right" style="border-left:1px solid #ccc" ><strong>Google :</strong></td> <td> <select name="wsl_settings_contacts_import_google" <?php if (!get_option('wsl_settings_Google_enabled')) { echo "disabled"; } ?> > <option <?php if (get_option('wsl_settings_contacts_import_google') == 1) { echo "selected"; } ?> value="1"><?php _wsl_e("Enabled", 'wordpress-social-login'); ?> </option> <option <?php if (get_option('wsl_settings_contacts_import_google') == 2) { echo "selected"; } ?> value="2"><?php _wsl_e("Disabled", 'wordpress-social-login'); ?> </option> </select> </td> <td align="right" style="border-left:1px solid #ccc" ><strong>Twitter :</strong></td> <td> <select name="wsl_settings_contacts_import_twitter" <?php if (!get_option('wsl_settings_Twitter_enabled')) { echo "disabled"; } ?> > <option <?php if (get_option('wsl_settings_contacts_import_twitter') == 1) { echo "selected"; } ?> value="1"><?php _wsl_e("Enabled", 'wordpress-social-login'); ?> </option> <option <?php if (get_option('wsl_settings_contacts_import_twitter') == 2) { echo "selected"; } ?> value="2"><?php _wsl_e("Disabled", 'wordpress-social-login'); ?> </option> </select> </td> <td align="right" style="border-left:1px solid #ccc" ><strong>Windows Live :</strong></td> <td> <select name="wsl_settings_contacts_import_live" <?php if (!get_option('wsl_settings_Live_enabled')) { echo "disabled"; } ?> > <option <?php if (get_option('wsl_settings_contacts_import_live') == 1) { echo "selected"; } ?> value="1"><?php _wsl_e("Enabled", 'wordpress-social-login'); ?> </option> <option <?php if (get_option('wsl_settings_contacts_import_live') == 2) { echo "selected"; } ?> value="2"><?php _wsl_e("Disabled", 'wordpress-social-login'); ?> </option> </select> </td> <td align="right" style="border-left:1px solid #ccc" ><strong>LinkedIn :</strong></td> <td> <select name="wsl_settings_contacts_import_linkedin" <?php if (!get_option('wsl_settings_LinkedIn_enabled')) { echo "disabled"; } ?> > <option <?php if (get_option('wsl_settings_contacts_import_linkedin') == 1) { echo "selected"; } ?> value="1"><?php _wsl_e("Enabled", 'wordpress-social-login'); ?> </option> <option <?php if (get_option('wsl_settings_contacts_import_linkedin') == 2) { echo "selected"; } ?> value="2"><?php _wsl_e("Disabled", 'wordpress-social-login'); ?> </option> </select> </td> </tr> </table> <p> <b style="color:#CB4B16;"><?php _wsl_e("Notes", 'wordpress-social-login'); ?> :</b> <ul style="margin-left:40px;margin-top:0px;"> <li><?php _wsl_e('To enable contacts import from these social network, you need first to enabled them on the <a href="options-general.php?page=wordpress-social-login&wslp=networks"><b>Networks</b></a> tab and register the required application', 'wordpress-social-login'); ?> .</li> <li><?php _wsl_e("<b>WSL</b> will try to import as much information about a user contacts as he was able to pull from the social networks APIs.", 'wordpress-social-login'); ?> </li> <li><?php _wsl_e('All contacts data are sotred into your database on the table: <code>`wsluserscontacts`</code>', 'wordpress-social-login'); ?> .</li> </ul> </p> </div> </div> <br style="clear:both;" /> <div style="margin-left:5px;margin-top:-20px;"> <input type="submit" class="button-primary" value="<?php _wsl_e("Save Settings", 'wordpress-social-login'); ?> " /> </div> </div> </div> </form> <br style="clear:both;" /> <hr /> <h3><?php _wsl_e("Users contacts list preview", 'wordpress-social-login'); ?> </h3> <?php } // if( isset( $_REQUEST["uid"] ) && (int) $_REQUEST["uid"] ){ if ($user_id) { $display_name = wsl_get_user_data_by_user_id("display_name", $user_id); ?> <h3><?php echo sprintf(_wsl__("%s contact's list", 'wordpress-social-login'), $display_name); ?> </h3> <?php } ?> <table cellspacing="0" class="wp-list-table widefat fixed users"> <thead> <tr> <th width="100"><span><?php _wsl_e("Provider", 'wordpress-social-login'); ?> </span></th> <th><span><?php _wsl_e("User", 'wordpress-social-login'); ?> </span></th> <th><span><?php _wsl_e("Contact Name", 'wordpress-social-login'); ?> </span></th> <th><span><?php _wsl_e("Contact Email", 'wordpress-social-login'); ?> </span></th> <th><span><?php _wsl_e("Contact Profile Url", 'wordpress-social-login'); ?> </span></th> </tr> </thead> <tfoot> <tr> <th><span><?php _wsl_e("Provider", 'wordpress-social-login'); ?> </span></th> <th><span><?php _wsl_e("User", 'wordpress-social-login'); ?> </span></th> <th><span><?php _wsl_e("Contact Name", 'wordpress-social-login'); ?> </span></th> <th><span><?php _wsl_e("Contact Email", 'wordpress-social-login'); ?> </span></th> <th><span><?php _wsl_e("Contact Profile Url", 'wordpress-social-login'); ?> </span></th> </tr> </tfoot> <tbody id="the-list"> <?php $sql = "SELECT * FROM `{$wpdb->prefix}wsluserscontacts` order by rand() limit 10"; if ($user_id) { $sql = "SELECT * FROM `{$wpdb->prefix}wsluserscontacts` WHERE user_id = '{$user_id}'"; } $rs1 = $wpdb->get_results($sql); // have contacts? if (!$rs1) { ?> <tr class="no-items"><td colspan="5" class="colspanchange"><?php _wsl_e("No contacts found", 'wordpress-social-login'); ?> .</td></tr> <?php } else { $i = 0; foreach ($rs1 as $item) { $provider = $item->provider; $user_id = $item->user_id; $contact_id = $item->id; ?> <tr class="<?php if (++$i % 2) { echo "alternate"; } ?> "> <td><img src="<?php $provider = wsl_get_contact_data_by_user_id("provider", $contact_id); echo $assets_base_url . strtolower($provider) . '.png'; ?> " style="vertical-align:top;width:16px;height:16px;" /> <?php echo $provider; ?> </td> <td> <?php // check if user exists if (wsl_get_user_by_meta_key_and_user_id("wsl_user", $user_id)) { ?> <?php $wsl_user_image = wsl_get_user_by_meta_key_and_user_id("wsl_user_image", $user_id); if ($wsl_user_image) { ?> <img width="32" height="32" class="avatar avatar-32 photo" src="<?php echo $wsl_user_image; ?> " > <?php } else { ?> <img width="32" height="32" class="avatar avatar-32 photo" src="http://1.gravatar.com/avatar/d4ed6debc848ece02976aba03e450d60?s=32" > <?php } ?> <strong><a href="user-edit.php?user_id=<?php echo $user_id; ?> "><?php echo wsl_get_user_by_meta_key_and_user_id("nickname", $user_id); ?> </a></strong> (<?php echo wsl_get_user_by_meta_key_and_user_id("last_name", $user_id); ?> <?php echo wsl_get_user_by_meta_key_and_user_id("first_name", $user_id); ?> ) <?php } else { echo "User removed"; } ?> <br> </td> <td> <?php $photo_url = wsl_get_contact_data_by_user_id("photo_url", $contact_id); if ($photo_url) { ?> <img width="32" height="32" class="avatar avatar-32 photo" src="<?php echo $photo_url; ?> " > <?php } else { ?> <img width="32" height="32" class="avatar avatar-32 photo" src="http://1.gravatar.com/avatar/d4ed6debc848ece02976aba03e450d60?s=32" > <?php } ?> <strong><?php echo wsl_get_contact_data_by_user_id("full_name", $contact_id); ?> </strong> <br> </td> <td> <?php $email = wsl_get_contact_data_by_user_id("email", $contact_id); if ($email) { ?> <a href="mailto:<?php echo $email; ?> "><?php echo $email; ?> </a> <?php } else { ?> - <?php } ?> </td> <td> <?php $profile_url = wsl_get_contact_data_by_user_id("profile_url", $contact_id); if ($profile_url) { ?> <a href="<?php echo $profile_url; ?> " target="_blank"><?php echo str_ireplace(array("http://www.", "https://www.", "http://", "https://"), array('', '', '', '', ''), $profile_url); ?> </a> <?php } else { ?> - <?php } ?> </td> </tr> <?php } } ?> </tbody> </table> </div> <?php // HOOKABLE: do_action("wsl_component_contacts_end"); }
function wsl_component_authtest() { // HOOKABLE: do_action("wsl_component_authtest_start"); $adapter = null; $provider_id = isset($_REQUEST["provider"]) ? $_REQUEST["provider"] : null; $user_profile = null; $assets_base_url = WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL . 'assets/img/'; if (!class_exists('Hybrid_Auth', false)) { require_once WORDPRESS_SOCIAL_LOGIN_ABS_PATH . "hybridauth/Hybrid/Auth.php"; } try { $provider = Hybrid_Auth::getAdapter($provider_id); // make as few call as possible if (!(isset($_SESSION['wsl::userprofile']) && $_SESSION['wsl::userprofile'] && ($user_profile = json_decode($_SESSION['wsl::userprofile'])))) { $user_profile = $provider->getUserProfile(); $_SESSION['wsl::userprofile'] = json_encode($user_profile); } $adapter = $provider->adapter; } catch (Exception $e) { } $ha_profile_fields = array(array('field' => 'identifier', 'label' => _wsl__("Provider user ID", 'wordpress-social-login')), array('field' => 'profileURL', 'label' => _wsl__("Profile URL", 'wordpress-social-login')), array('field' => 'webSiteURL', 'label' => _wsl__("Website URL", 'wordpress-social-login')), array('field' => 'photoURL', 'label' => _wsl__("Photo URL", 'wordpress-social-login')), array('field' => 'displayName', 'label' => _wsl__("Display name", 'wordpress-social-login')), array('field' => 'description', 'label' => _wsl__("Description", 'wordpress-social-login')), array('field' => 'firstName', 'label' => _wsl__("First name", 'wordpress-social-login')), array('field' => 'lastName', 'label' => _wsl__("Last name", 'wordpress-social-login')), array('field' => 'gender', 'label' => _wsl__("Gender", 'wordpress-social-login')), array('field' => 'language', 'label' => _wsl__("Language", 'wordpress-social-login')), array('field' => 'age', 'label' => _wsl__("Age", 'wordpress-social-login')), array('field' => 'birthDay', 'label' => _wsl__("Birth day", 'wordpress-social-login')), array('field' => 'birthMonth', 'label' => _wsl__("Birth month", 'wordpress-social-login')), array('field' => 'birthYear', 'label' => _wsl__("Birth year", 'wordpress-social-login')), array('field' => 'email', 'label' => _wsl__("Email", 'wordpress-social-login')), array('field' => 'phone', 'label' => _wsl__("Phone", 'wordpress-social-login')), array('field' => 'address', 'label' => _wsl__("Address", 'wordpress-social-login')), array('field' => 'country', 'label' => _wsl__("Country", 'wordpress-social-login')), array('field' => 'region', 'label' => _wsl__("Region", 'wordpress-social-login')), array('field' => 'city', 'label' => _wsl__("City", 'wordpress-social-login')), array('field' => 'zip', 'label' => _wsl__("Zip", 'wordpress-social-login'))); ?> <style> .widefat td, .widefat th { border: 1px solid #DDDDDD; } .widefat th label { font-weight: bold; } .wp-social-login-provider-list { padding: 10px; } .wp-social-login-provider-list a {text-decoration: none; } .wp-social-login-provider-list img{ border: 0 none; } </style> <div class="metabox-holder columns-2" id="post-body"> <table width="100%"> <tr valign="top"> <td> <?php if (!$adapter) { ?> <div style="padding: 15px; margin-bottom: 8px; border: 1px solid #ddd; background-color: #fff;box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);"> <p><?php _wsl_e("Connect with a provider to get started", 'wordpress-social-login'); ?> .</p> </div> <?php } else { ?> <div class="stuffbox"> <h3> <label><?php _wsl_e("Connected adapter specs", 'wordpress-social-login'); ?> </label> </h3> <div class="inside"> <table class="wp-list-table widefat"> <tr> <th width="200"><label><?php _wsl_e("Provider", 'wordpress-social-login'); ?> </label></th> <td><?php echo $adapter->providerId; ?> </td> </tr> <?php if (isset($adapter->openidIdentifier)) { ?> <tr> <th width="200"><label><?php _wsl_e("OpenID Identifier", 'wordpress-social-login'); ?> </label></th> <td><?php echo $adapter->openidIdentifier; ?> </td> </tr> <?php } ?> <?php if (isset($adapter->scope)) { ?> <tr> <th width="200"><label><?php _wsl_e("Scope", 'wordpress-social-login'); ?> </label></th> <td><?php echo $adapter->scope; ?> </td> </tr> <?php } ?> <?php if (isset($adapter->config['keys'])) { ?> <tr> <th width="200"><label><?php _wsl_e("Application keys", 'wordpress-social-login'); ?> </label></th> <td><div style="max-width:650px"><?php echo json_encode($adapter->config['keys']); ?> </div></td> </tr> <?php } ?> <?php if ($adapter->token("access_token")) { ?> <tr> <th width="200"><label><?php _wsl_e("Access token", 'wordpress-social-login'); ?> </label></th> <td><div style="max-width:650px"><?php echo $adapter->token("access_token"); ?> </div></td> </tr> <?php } ?> <?php if ($adapter->token("access_token_secret")) { ?> <tr> <th width="200"><label><?php _wsl_e("Access token secret", 'wordpress-social-login'); ?> </label></th> <td><?php echo $adapter->token("access_token_secret"); ?> </td> </tr> <?php } ?> <?php if ($adapter->token("expires_in")) { ?> <tr> <th width="200"><label><?php _wsl_e("Access token expires in", 'wordpress-social-login'); ?> </label></th> <td><?php echo (int) $adapter->token("expires_at") - time(); ?> <?php _wsl_e("second(s)", 'wordpress-social-login'); ?> </td> </tr> <?php } ?> <?php if ($adapter->token("expires_at")) { ?> <tr> <th width="200"><label><?php _wsl_e("Access token expires at", 'wordpress-social-login'); ?> </label></th> <td><?php echo date(DATE_W3C, $adapter->token("expires_at")); ?> </td> </tr> <?php } ?> </table> </div> </div> <?php $console = false; if (!isset($adapter->openidIdentifier)) { ?> <div class="stuffbox"> <h3> <label><?php _wsl_e("Connected adapter console", 'wordpress-social-login'); ?> </label> </h3> <div class="inside"> <?php $path = isset($adapter->api->api_base_url) ? $adapter->api->api_base_url : ''; $path = isset($_REQUEST['console-path']) ? $_REQUEST['console-path'] : $path; $method = isset($_REQUEST['console-method']) ? $_REQUEST['console-method'] : ''; $query = isset($_REQUEST['console-query']) ? $_REQUEST['console-query'] : ''; $response = ''; if ($path && in_array($method, array('GET', 'POST'))) { $console = true; try { if ($method == 'GET') { $response = $adapter->api->get($path . ($query ? '?' . $query : '')); } else { $response = $adapter->api->get($path, $query); } $response = $response ? $response : Hybrid_Error::getApiError(); } catch (Exception $e) { $response = "ERROR: " . $e->getMessage(); } } ?> <form action="" method="post"/> <table class="wp-list-table widefat"> <tr> <th width="200"><label><?php _wsl_e("Path", 'wordpress-social-login'); ?> </label></th> <td><input type="text" style="width:96%" name="console-path" value="<?php echo htmlentities($path); ?> "><a href="https://apigee.com/providers" target="_blank"><img src="<?php echo $assets_base_url . 'question.png'; ?> " style="vertical-align: text-top;" /></a></td> </tr> <tr> <th width="200"><label><?php _wsl_e("Method", 'wordpress-social-login'); ?> </label></th> <td><select style="width:100px" name="console-method"><option value="GET" <?php if ($method == 'GET') { echo 'selected'; } ?> >GET</option><!-- <option value="POST" <?php if ($method == 'POST') { echo 'selected'; } ?> >POST</option>--></select></td> </tr> <tr> <th width="200"><label><?php _wsl_e("Query", 'wordpress-social-login'); ?> </label></th> <td><textarea style="width:100%;height:60px;margin-top:6px;" name="console-query"><?php echo htmlentities($query); ?> </textarea></td> </tr> </table> <br /> <input type="submit" value="<?php _wsl_e("Submit", 'wordpress-social-login'); ?> " class="button"> </form> </div> </div> <?php if ($console) { ?> <div class="stuffbox"> <h3> <label><?php _wsl_e("API Response", 'wordpress-social-login'); ?> </label> </h3> <div class="inside"> <textarea rows="25" cols="70" wrap="off" style="width:100%;height:400px;margin-bottom:15px;font-family: monospace;font-size: 12px;"><?php echo htmlentities(print_r($response, true)); ?> </textarea> </div> </div> <?php if (0) { ?> <div class="stuffbox"> <h3> <label><?php _wsl_e("Code PHP", 'wordpress-social-login'); ?> </label> </h3> <div class="inside"> <textarea rows="25" cols="70" wrap="off" style="width:100%;height:210px;margin-bottom:15px;font-family: monospace;font-size: 12px;" >include_once WORDPRESS_SOCIAL_LOGIN_ABS_PATH . 'hybridauth/Hybrid/Auth.php'; /*! Important Direct access to providers apis is newly introduced into WSL and we are still experimenting, so they may change in future releases. */ try { $<?php echo strtolower($adapter->providerId); ?> = Hybrid_Auth::getAdapter( '<?php echo htmlentities($provider_id); ?> ' ); <?php if ($method == 'GET') { ?> $response = $<?php echo strtolower($adapter->providerId); ?> ->api()->get( '<?php echo htmlentities($path . ($query ? '?' . $query : '')); ?> ' ); <?php } else { ?> $response = $<?php echo strtolower($adapter->providerId); ?> ->api()->post( '<?php echo htmlentities($path); ?> ', (array) $query ); <?php } ?> } catch( Exception $e ) { echo "Ooophs, we got an error: " . $e->getMessage(); }</textarea> </div> </div> <div class="stuffbox"> <h3> <label><?php _wsl_e("Connected adapter debug", 'wordpress-social-login'); ?> </label> </h3> <div class="inside"> <textarea rows="25" cols="70" wrap="off" style="width:100%;height:400px;margin-bottom:15px;font-family: monospace;font-size: 12px;"><?php echo htmlentities(print_r($adapter, true)); ?> </textarea> </div> </div> <div class="stuffbox"> <h3> <label><?php _wsl_e("PHP Session", 'wordpress-social-login'); ?> </label> </h3> <div class="inside"> <textarea rows="25" cols="70" wrap="off" style="width:100%;height:350px;margin-bottom:15px;font-family: monospace;font-size: 12px;"><?php echo htmlentities(print_r($_SESSION, true)); ?> </textarea> </div> </div> <?php } ?> <?php } ?> <?php } ?> <?php if (!$console) { ?> <div class="stuffbox"> <h3> <label><?php _wsl_e("Connected user social profile", 'wordpress-social-login'); ?> </label> </h3> <div class="inside"> <table class="wp-list-table widefat"> <?php $user_profile = (array) $user_profile; foreach ($ha_profile_fields as $item) { $item['field'] = $item['field']; ?> <tr> <th width="200"> <label><?php echo $item['label']; ?> </label> </th> <td> <?php if (isset($user_profile[$item['field']]) && $user_profile[$item['field']]) { $field_value = $user_profile[$item['field']]; if (in_array(strtolower($item['field']), array('profileurl', 'websiteurl', 'email'))) { ?> <a href="<?php if ($item['field'] == 'email') { echo 'mailto:'; } echo $field_value; ?> " target="_blank"><?php echo $field_value; ?> </a> <?php } elseif (strtolower($item['field']) == 'photourl') { ?> <a href="<?php echo $field_value; ?> " target="_blank"><img width="36" height="36" align="left" src="<?php echo $field_value; ?> " style="margin-right: 5px;" > <?php echo $field_value; ?> </a> <?php } else { echo $field_value; } } ?> </td> </tr> <?php } ?> </table> </div> </div> <?php } ?> <?php } ?> </td> <td width="10"></td> <td width="400"> <div class="postbox"> <div class="inside"> <h3><?php _wsl_e("Authentication Playground", 'wordpress-social-login'); ?> </h3> <div style="padding:0 20px;"> <p> <?php _wsl_e('Authentication Playground will let you authenticate with the enabled social networks without creating any new user account', 'wordpress-social-login'); ?> . </p> <p> <?php _wsl_e('This tool will also give you a direct access to social networks apis via a lightweight console', 'wordpress-social-login'); ?> . </p> </div> </div> </div> </style> <div class="postbox"> <div class="inside"> <div style="padding:0 20px;"> <p> <?php _wsl_e("Connect with", 'wordpress-social-login'); ?> : </p> <div style="width: 380px; padding: 10px; border: 1px solid #ddd; background-color: #fff;"> <?php do_action('wordpress_social_login', array('mode' => 'test', 'caption' => '')); ?> </div> </div> </div> </div> </td> </tr> </table> </div> <?php // HOOKABLE: do_action("wsl_component_authtest_end"); }
function wsl_component_watchdog_database() { $assets_base_url = WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL . 'assets/img/16x16/'; global $wpdb; // If action eq delete WSL user profiles if (isset($_REQUEST['delete']) && isset($_REQUEST['_wpnonce']) && wp_verify_nonce($_REQUEST['_wpnonce'])) { if ($_REQUEST['delete'] == 'log') { $wpdb->query("TRUNCATE TABLE {$wpdb->prefix}wslwatchdog"); } } ?> <style> .widefatop td, .widefatop th { border: 1px solid #DDDDDD; } .widefatop th label { font-weight: bold; } </style> <div style="padding: 5px 20px; border: 1px solid #ddd; background-color: #fff;"> <h3><?php _wsl_e("Authentication log viewer - latest activity", 'wordpress-social-login'); ?> </h3> <p style="float: right;margin-top:-45px"> <?php $delete_url = wp_nonce_url('options-general.php?page=wordpress-social-login&wslp=watchdog&delete=log'); ?> <a class="button button-secondary" style="background-color: #da4f49;border-color: #bd362f;text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);color: #ffffff;" href="<?php echo $delete_url; ?> " onClick="return confirm('Are you sure?');"><?php _wsl_e("Delete WSL Log", 'wordpress-social-login'); ?> </a> </p> <hr /> <?php $list_sessions = $wpdb->get_results("SELECT user_ip, session_id, provider, max(id) as max_id FROM `{$wpdb->prefix}wslwatchdog` GROUP BY session_id, provider ORDER BY max_id DESC LIMIT 25"); if (!$list_sessions) { _wsl_e("<p>No log found!</p>", 'wordpress-social-login'); } else { foreach ($list_sessions as $seesion_data) { $user_ip = $seesion_data->user_ip; $session_id = $seesion_data->session_id; $provider = $seesion_data->provider; if (!$provider) { continue; } ?> <div style="padding: 15px; margin-bottom: 8px; border: 1px solid #ddd; background-color: #fff;box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);"> <img src="<?php echo $assets_base_url . strtolower($provider) . '.png'; ?> " style="vertical-align:top;width:16px;height:16px;" /> <?php echo sprintf(_wsl__("<b>%s</b> : %s - %s", 'wordpress-social-login'), $provider, $user_ip, $session_id); ?> </div> <table class="wp-list-table widefat widefatop"> <tr> <th>#</th> <th>Action</th> <th>Args</th> <th>Time</th> <th>User</th> <th style="text-align:center">Δ</th> </tr> <?php $list_calls = $wpdb->get_results("SELECT * FROM `{$wpdb->prefix}wslwatchdog` WHERE session_id = '{$session_id}' AND provider = '{$provider}' ORDER BY id ASC LIMIT 500"); $abandon = false; $newattempt = false; $newsession = true; $functcalls = 0; $exectime = 0; $oexectime = 0; $texectime = 0; foreach ($list_calls as $call_data) { $exectime = (double) $call_data->created_at - ($oexectime ? $oexectime : (double) $call_data->created_at); $oexectime = (double) $call_data->created_at; $texectime += $exectime; $call_data->action_args = json_decode($call_data->action_args); $newattempt = false; $action_name_uid = uniqid(); $action_desc = 'N.A.'; ?> <tr style="<?php if (stristr($call_data->action_name, 'dbg:')) { echo 'background-color:#fffcf5;'; } ?> <?php if ('wsl_render_login_form_user_loggedin' == $call_data->action_name || $call_data->action_name == 'wsl_hook_process_login_before_wp_set_auth_cookie') { echo 'background-color:#edfff7;'; } if ('wsl_process_login_complete_registration_start' == $call_data->action_name) { echo 'background-color:#fefff0;'; } if ('wsl_process_login_render_error_page' == $call_data->action_name || $call_data->action_name == 'wsl_process_login_render_notice_page') { echo 'background-color:#fffafa;'; } ?> "> <td nowrap width="10"> <?php echo $call_data->id; ?> </td> <td nowrap width="350"> <span style="color:#<?php if (stristr($call_data->action_name, 'dbg:')) { echo '333333'; } if ('wsl_hook_process_login_before_wp_safe_redirect' == $call_data->action_name) { echo 'a6354b'; } if ('wsl_hook_process_login_before_wp_set_auth_cookie' == $call_data->action_name) { echo '9035a6'; } if ('wsl_process_login_render_error_page' == $call_data->action_name) { echo 'f50505'; } if ('wsl_process_login_render_notice_page' == $call_data->action_name) { echo 'fa1797'; } ?> " ><?php echo $call_data->action_name; ?> </span> </td> <td> <span style="float:right;"><a style="font-size:25px" href="javascript:void(0);" onClick="action_args_toggle( '<?php echo $action_name_uid; ?> ' )">+</a></span> <a href="javascript:alert('<?php echo $call_data->url; ?> ');"> <small> <?php echo substr($call_data->url, 0, 100); echo strlen($call_data->url) > 100 ? '...' : ''; ?> </small> </a> <pre style="display:none; overflow:scroll; background-color:#fcfcfc; color:#808080;font-size:11px;max-width:750px;" class="action_args_<?php echo $action_name_uid; ?> "><?php echo htmlentities(print_r($call_data->action_args, true)); ?> </pre> </td> <td nowrap width="115"> <?php echo date("Y-m-d h:i:s", $call_data->created_at); ?> </td> <td nowrap width="40"> <?php if ($call_data->user_id) { echo '<a href="options-general.php?page=wordpress-social-login&wslp=users&uid=' . $call_data->user_id . '">#' . $call_data->user_id . '</a>'; } ?> </td> <td nowrap width="10" style="<?php if ($exectime > 0.5) { echo 'color: #f44 !important;'; } ?> "> <?php echo number_format($exectime, 3, '.', ''); ?> </td> </tr> <?php } ?> </table> <?php echo number_format($texectime, 3, '.', ''); echo '<br />'; } } ?> <script> function action_args_toggle( action ) { jQuery('.action_args_' + action ).toggle(); return false; } </script> </div> <?php }
function wsl_check_requirements() { if (!version_compare(PHP_VERSION, '5.2.0', '>=') || !isset($_SESSION["wsl::plugin"]) || !function_exists('curl_init') || !function_exists('json_decode')) { return false; } $curl_version = curl_version(); if (!($curl_version['features'] & CURL_VERSION_SSL)) { return false; } return true; } // -------------------------------------------------------------------- /** list of WSL components */ $WORDPRESS_SOCIAL_LOGIN_COMPONENTS = array("core" => array("type" => "core", "label" => _wsl__("WSL Core", 'wordpress-social-login'), "description" => _wsl__("WordPress Social Login core.", 'wordpress-social-login')), "networks" => array("type" => "core", "label" => _wsl__("Networks", 'wordpress-social-login'), "description" => _wsl__("Social networks setup.", 'wordpress-social-login')), "login-widget" => array("type" => "core", "label" => _wsl__("Widget", 'wordpress-social-login'), "description" => _wsl__("Authentication widget customization.", 'wordpress-social-login')), "bouncer" => array("type" => "core", "label" => _wsl__("Bouncer", 'wordpress-social-login'), "description" => _wsl__("WordPress Social Login advanced configuration.", 'wordpress-social-login')), "users" => array("type" => "addon", "label" => _wsl__("Users", 'wordpress-social-login'), "description" => _wsl__("WordPress Social Login users manager.", 'wordpress-social-login')), "contacts" => array("type" => "addon", "label" => _wsl__("Contacts", 'wordpress-social-login'), "description" => _wsl__("WordPress Social Login users contacts manager", 'wordpress-social-login')), "buddypress" => array("type" => "addon", "label" => _wsl__("BuddyPress", 'wordpress-social-login'), "description" => _wsl__("Makes WordPress Social Login compatible with BuddyPress: Widget integration, Users avatars and xProfiles mapping.", 'wordpress-social-login'))); /** list of WSL admin tabs */ $WORDPRESS_SOCIAL_LOGIN_ADMIN_TABS = array("networks" => array("label" => _wsl__("Networks", 'wordpress-social-login'), "visible" => true, "component" => "networks", "default" => true), "login-widget" => array("label" => _wsl__("Widget", 'wordpress-social-login'), "visible" => true, "component" => "login-widget"), "bouncer" => array("label" => _wsl__("Bouncer", 'wordpress-social-login'), "visible" => true, "component" => "bouncer"), "users" => array("label" => _wsl__("Users", 'wordpress-social-login'), "visible" => true, "component" => "users"), "contacts" => array("label" => _wsl__("Contacts", 'wordpress-social-login'), "visible" => true, "component" => "contacts"), "buddypress" => array("label" => _wsl__("BuddyPress", 'wordpress-social-login'), "visible" => true, "component" => "buddypress"), "help" => array("label" => _wsl__('Help', 'wordpress-social-login'), "visible" => true, "component" => "core", "pull-right" => true, 'ico' => 'info.png'), "tools" => array("label" => _wsl__("Tools", 'wordpress-social-login'), "visible" => true, "component" => "core", "pull-right" => true, 'ico' => 'tools.png'), "watchdog" => array("label" => _wsl__("Log viewer", 'wordpress-social-login'), "visible" => false, "component" => "core", "pull-right" => true, 'ico' => 'debug.png'), "auth-paly" => array("label" => _wsl__("Auth test", 'wordpress-social-login'), "visible" => false, "component" => "core", "pull-right" => true, 'ico' => 'magic.png'), "components" => array("label" => _wsl__("Components", 'wordpress-social-login'), "visible" => true, "component" => "core", "pull-right" => true, 'ico' => 'components.png')); // -------------------------------------------------------------------- /** * Register a new WSL component */ function wsl_register_component($component, $label, $description, $version, $author, $author_url, $component_url) { global $WORDPRESS_SOCIAL_LOGIN_COMPONENTS; $config = array(); $config["type"] = "addon"; // < force to addon $config["label"] = $label; $config["description"] = $description; $config["version"] = $version; $config["author"] = $author; $config["author_url"] = $author_url;
function wsl_component_bouncer_setup_membership_level() { ?> <div class="stuffbox"> <h3> <label><?php _wsl_e("Membership level", 'wordpress-social-login'); ?> </label> </h3> <div class="inside"> <p> <?php _wsl_e("Here you can define the default role for new users authenticating through WSL", 'wordpress-social-login'); ?> . <?php _wsl_e("Please, be extra carefull with this option, you may be automatically giving someone elevated roles and capabilities", 'wordpress-social-login'); ?> . <?php _wsl_e('For more information about WordPress users roles and capabilities refer to <a href="http://codex.wordpress.org/Roles_and_Capabilities#Capability_vs._Role_Table" target="_blank">http://codex.wordpress.org/Roles_and_Capabilities</a>', 'wordpress-social-login'); ?> . </p> <p class="description"> <b><?php _wsl_e('Notes', 'wordpress-social-login'); ?> :</b> <br /><?php _wsl_e('1. If <b>User Moderation</b> is set to <code>Admin Approval</code>, then <b>Membership level</b> will be ignored', 'wordpress-social-login'); ?> . <br /><?php _wsl_e('2. To assign the same default role as in your website <b>General Settings</b>, set this field to <code>Wordpress User Default Role</code>', 'wordpress-social-login'); ?> . <br /><?php _wsl_e('3. If you are not sure, simply leave this field to <code>No role for this site</code>', 'wordpress-social-login'); ?> . </p> <table width="100%" border="0" cellpadding="5" cellspacing="2" style="border-top:1px solid #ccc;"> <tr> <td width="200" align="right" nowrap><strong><?php _wsl_e("New WSL users default role", 'wordpress-social-login'); ?> :</strong></td> <td> <select name="wsl_settings_bouncer_new_users_membership_default_role"> <optgroup label="<?php _wsl_e("Safe", 'wordpress-social-login'); ?> :"> <option value="default" <?php if (get_option('wsl_settings_bouncer_new_users_membership_default_role') == "default") { echo "selected"; } ?> ><?php _wsl_e("— Wordpress User Default Role —", 'wordpress-social-login'); ?> </option> <option value="wslnorole" <?php if (get_option('wsl_settings_bouncer_new_users_membership_default_role') == "wslnorole") { echo "selected"; } ?> ><?php _wsl_e("— No role for this site —", 'wordpress-social-login'); ?> </option> </optgroup> <optgroup label="<?php _wsl_e("Be careful with these", 'wordpress-social-login'); ?> :"> <?php global $wp_roles; $users_membership_roles = apply_filters('wsl_component_bouncer_setup_alter_users_membership_roles', $wp_roles->role_names); foreach ($users_membership_roles as $role => $name) { ?> <option value="<?php echo $role; ?> " <?php if (get_option('wsl_settings_bouncer_new_users_membership_default_role') == $role) { echo "selected"; } ?> ><?php _wsl_e($name, 'wordpress-social-login'); ?> </option> <?php } ?> </optgroup> </select> </td> </tr> <tr> <td colspan="2"> <div class="fade updated"> <p> <?php $role = get_option('wsl_settings_bouncer_new_users_membership_default_role'); $role = $role == 'default' ? get_option('default_role') : $role; $role = get_role($role); if ($role) { echo sprintf(_wsl__("<b>New WSL users default role</b> is currently set to <b>“%s”</b>, which gives these capabilities: ", 'wordpress-social-login'), get_option('wsl_settings_bouncer_new_users_membership_default_role')); $capabilities = array(); foreach ($role->capabilities as $k => $v) { if ($v && !stristr($k, 'level_')) { $capabilities[] = '<a href="http://codex.wordpress.org/Roles_and_Capabilities#' . $k . '" target="_blank">' . $k . '</a>'; } } echo implode(', ', $capabilities); } else { echo sprintf(_wsl__("<b>New WSL users default role</b> is currently set to <b>“%s”</b>, which gives NO capabilities", 'wordpress-social-login'), get_option('wsl_settings_bouncer_new_users_membership_default_role')); } ?> . </p> </div> </td> </tr> </table> </div> </div> <?php }
function wsl_component_users_profile($user_id) { // HOOKABLE: do_action("wsl_component_users_profile_start"); $linked_accounts = wsl_get_user_linked_account_by_user_id($user_id); if (!$linked_accounts) { _wsl_e("USER DOES NOT EXIST!", 'wordpress-social-login'); return; } $assets_base_url = WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL . '/assets/img/16x16/'; ?> <style> table td, table th { border: 1px solid #DDDDDD; } table th label { font-weight: bold; } .form-table th { width:120px; text-align:right; } </style> <p> <a class="button button-secondary" href="user-edit.php?user_id=<?php echo $user_id; ?> ">Edit User</a> <a class="button button-secondary" href="options-general.php?page=wordpress-social-login&wslp=contacts&uid=<?php echo $user_id; ?> ">Show User Contacts List</a> </p> <hr /> <?php foreach ($linked_accounts as $link) { ?> <h3><?php _wsl_e("User Profile", 'wordpress-social-login'); ?> <small><?php echo sprintf(_wsl__("as provided by %s", 'wordpress-social-login'), $link->provider); ?> </small></h3> <table class="form-table" <tr><th><label><?php echo $link->provider; ?> Identifier </label></th><td><?php echo $link->identifier; ?> <br /><span class="description">The Unique user's ID. Can be an interger for some providers, Email, URL, etc.</span></td></tr> <tr><th><label>Wordpress Identifier </label></th><td><?php echo $user_id; ?> <br /><span class="description">The Unique user's ID on your website.</span></td></tr> <tr><th><label>Profile URL </label></th><td><a href="<?php echo $link->profileurl; ?> "><?php echo $link->profileurl; ?> </a> <br /><span class="description">URL link to profile page on the <?php echo $link->provider; ?> web site.</span></td></tr> <tr><th><label>Website URL </label></th><td><a href="<?php echo $link->websiteurl; ?> "><?php echo $link->websiteurl; ?> </a> <br /><span class="description">User website, blog, web page, etc.</span></td></tr> <tr><th><label>Photo URL </label></th><td><a href="<?php echo $link->photourl; ?> "><?php echo $link->photourl; ?> </a> <br /><span class="description">URL link to user photo or avatar.</span></td></tr> <tr><th><label>Display name </label></th><td><?php echo $link->displayname; ?> <br /><span class="description">User dispaly Name provided by the <?php echo $link->provider; ?> or a concatenation of first and last name.</span></td></tr> <tr><th><label>Description </label></th><td><?php echo $link->description; ?> <tr><th><label>First name </label></th><td><?php echo $link->firstname; ?> <tr><th><label>Last name </label></th><td><?php echo $link->lastname; ?> <tr><th><label>Gender </label></th><td><?php echo $link->gender; ?> <tr><th><label>Language </label></th><td><?php echo $link->language; ?> <tr><th><label>Age </label></th><td><?php echo $link->age; ?> <tr><th><label>Birth day </label></th><td><?php echo $link->birthday; ?> <tr><th><label>Birth month </label></th><td><?php echo $link->birthmonth; ?> <tr><th><label>Birth year </label></th><td><?php echo $link->birthyear; ?> <tr><th><label>Email </label></th><td><?php echo $link->email; ?> <tr><th><label>Phone </label></th><td><?php echo $link->phone; ?> <tr><th><label>Address </label></th><td><?php echo $link->address; ?> <tr><th><label>Country </label></th><td><?php echo $link->country; ?> <tr><th><label>Region </label></th><td><?php echo $link->region; ?> <tr><th><label>City </label></th><td><?php echo $link->city; ?> <tr><th><label>Zip </label></th><td><?php echo $link->zip; ?> </tr> </table> <?php } // HOOKABLE: do_action("wsl_component_users_profile_end"); }
/** * Renders wsl admin welcome panel */ function wsl_admin_welcome_panel() { if (isset($_REQUEST["wsldwp"]) && (int) $_REQUEST["wsldwp"]) { $wsldwp = (int) $_REQUEST["wsldwp"]; update_option("wsl_settings_welcome_panel_enabled", wsl_version()); return; } // if new user or wsl updated, then we display wsl welcome panel if (get_option('wsl_settings_welcome_panel_enabled') == wsl_version()) { return; } ?> <!-- if you want to know if a UI was made by devloper, then here is a tip: he will always use tables //> wsl-w-panel is shamelessly borrowered and modified from wordpress welcome-panel --> <div id="wsl-w-panel"> <a href="options-general.php?page=wordpress-social-login&wslp=<?php echo $wslp; ?> &wsldwp=1" id="wsl-w-panel-dismiss"><?php _e("Dismiss", 'wordpress-social-login'); ?> </a> <table width="100%" border="0" style="margin:0;padding:0;"> <tr> <td width="10" valign="top"></td> <td width="300" valign="top"> <b style="font-size: 16px;"><?php _wsl_e("Welcome!", 'wordpress-social-login'); ?> </b> <p> <?php _wsl_e("If you are still new to WordPress Social Login, we have provided a few walkthroughs to get you started", 'wordpress-social-login'); ?> . </p> </td> <td width="40" valign="top"></td> <td width="260" valign="top"> <br /> <p> <b><?php _wsl_e("Get Started", 'wordpress-social-login'); ?> </b> </p> <ul style="margin-left:25px;"> <li><?php _wsl_e('<a href="http://hybridauth.sourceforge.net/wsl/configure.html" target="_blank">Setup and Configuration</a>', 'wordpress-social-login'); ?> </li> <li><?php _wsl_e('<a href="http://hybridauth.sourceforge.net/wsl/customize.html" target="_blank">Customize WSL Widgets</a>', 'wordpress-social-login'); ?> </li> <li><?php _wsl_e('<a href="http://hybridauth.sourceforge.net/wsl/userdata.html" target="_blank">Manage users and contacts</a>', 'wordpress-social-login'); ?> </li> <li><?php _wsl_e('<a href="http://hybridauth.sourceforge.net/wsl/index.html" target="_blank">WSL User Guide</a> and <a href="http://hybridauth.sourceforge.net/wsl/faq.html" target="_blank">FAQ</a>', 'wordpress-social-login'); ?> </li> </ul> </td> <td width="" valign="top"> <br /> <p> <b><?php echo sprintf(_wsl__("What's new on WSL %s", 'wordpress-social-login'), wsl_version()); ?> </b> </p> <ul style="margin-left:25px;"> <li><?php _wsl_e('In a similar way to WordPress plugins, WSL uses <a href="options-general.php?page=wordpress-social-login&wslp=components">Components</a>', 'wordpress-social-login'); ?> ,</li> <li><?php _wsl_e('<b>Email Validation</b> is replaced with <b>Profile Completion</b>', 'wordpress-social-login'); ?> ,</li> <li><?php _wsl_e('<b>User Moderation</b> made compatible with <a href="http://wordpress.org/extend/plugins/theme-my-login/" target="_blank">Theme My Login</a> plugin', 'wordpress-social-login'); ?> ,</li> <li><?php _wsl_e('A number of enhancements and new options now available', 'wordpress-social-login'); ?> .</li> </ul> </td> </tr> <tr id="wsl-w-panel-updates-tr"> <td colspan="5" style="border-top:1px solid #ccc;" id="wsl-w-panel-updates-td"> </td> </tr> </table> </div> <?php }
/** * Display an error message in case user authentication fails */ function wsl_process_login_render_error_page($e, $config = null, $provider = null, $adapter = null) { // HOOKABLE: do_action("wsl_process_login_render_error_page", $e, $config, $provider, $adapter); $assets_base_url = WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL . 'assets/img/'; $message = _wsl__("Unspecified error!", 'wordpress-social-login'); $notes = ""; $apierror = substr($e->getMessage(), 0, 145); switch ($e->getCode()) { case 0: $message = _wsl__("Unspecified error.", 'wordpress-social-login'); break; case 1: $message = _wsl__("WordPress Social Login is not properly configured.", 'wordpress-social-login'); break; case 2: $message = sprintf(__wsl__("WordPress Social Login is not properly configured.<br /> <b>%s</b> need to be properly configured.", 'wordpress-social-login'), $provider); break; case 3: $message = _wsl__("Unknown or disabled provider.", 'wordpress-social-login'); break; case 4: $message = sprintf(_wsl__("WordPress Social Login is not properly configured.<br /> <b>%s</b> requires your application credentials.", 'wordpress-social-login'), $provider); $notes = sprintf(_wsl__("<b>What does this error mean ?</b><br />Most likely, you didn't setup the correct application credentials for this provider. These credentials are required in order for <b>%s</b> users to access your website and for WordPress Social Login to work.", 'wordpress-social-login'), $provider) . _wsl__('<br />Instructions for use can be found in the <a href="http://miled.github.io/wordpress-social-login/networks.html" target="_blank">User Manual</a>.', 'wordpress-social-login'); break; case 5: $message = sprintf(_wsl__("Authentication failed. Either you have cancelled the authentication or <b>%s</b> refused the connection.", 'wordpress-social-login'), $provider); break; case 6: $message = sprintf(_wsl__("Request failed. Either you have cancelled the authentication or <b>%s</b> refused the connection.", 'wordpress-social-login'), $provider); break; case 7: $message = _wsl__("You're not connected to the provider.", 'wordpress-social-login'); break; case 8: $message = _wsl__("Provider does not support this feature.", 'wordpress-social-login'); break; } if (is_object($adapter)) { $adapter->logout(); } // provider api response if (class_exists('Hybrid_Error', false) && Hybrid_Error::getApiError()) { $tmp = Hybrid_Error::getApiError(); $apierror = $apierror . "\n" . '<br />' . $tmp; // network issue if (trim($tmp) == '0.') { $apierror = "Could not establish connection to provider API"; } } return wsl_render_error_page($message, $notes, $provider, $apierror, $e); }
function wsl_process_login_complete_registration($provider, $redirect_to, $hybridauth_user_profile) { // HOOKABLE: do_action("wsl_process_login_complete_registration_start", $provider, $redirect_to, $hybridauth_user_profile); $hybridauth_user_email = sanitize_email($hybridauth_user_profile->email); $hybridauth_user_login = sanitize_user($hybridauth_user_profile->displayName, true); $hybridauth_user_avatar = $hybridauth_user_profile->photoURL; $request_user_login = isset($_REQUEST["user_login"]) ? $_REQUEST["user_login"] : ''; $request_user_email = isset($_REQUEST["user_email"]) ? $_REQUEST["user_email"] : ''; $request_user_login = sanitize_user($request_user_login, true); $request_user_email = sanitize_email($request_user_email); $request_user_login = trim(str_replace(array(' ', '.'), '_', $request_user_login)); $request_user_login = trim(str_replace('__', '_', $request_user_login)); $request_user_login_exists = username_exists($request_user_login); $request_user_email_exists = wsl_wp_email_exists($request_user_email); $request_user_login_validate = validate_username($request_user_login); $request_user_email_validate = filter_var($request_user_email, FILTER_VALIDATE_EMAIL); if (empty($request_user_login)) { $request_user_login_validate = false; } if (empty($request_user_email)) { $request_user_email_validate = false; } if (empty($request_user_login)) { $request_user_login = $hybridauth_user_login; } if (empty($request_user_email)) { $request_user_email = $hybridauth_user_email; } $shall_pass = true; $shall_pass_errors = array(); // well until brain become able to compute again.. if (get_option('wsl_settings_bouncer_profile_completion_require_email') == 1) { if (!$request_user_email) { $shall_pass = false; $shall_pass_errors[_wsl__("E-mail is not valid!", 'wordpress-social-login')] = true; } if (!$request_user_email_validate) { $shall_pass = false; $shall_pass_errors[_wsl__("E-mail is not valid!", 'wordpress-social-login')] = true; } if ($request_user_email_exists) { $shall_pass = false; $shall_pass_errors[_wsl__("That E-mail is already registered!", 'wordpress-social-login')] = true; } } if (get_option('wsl_settings_bouncer_profile_completion_change_username') == 1) { if (!$request_user_login) { $shall_pass = false; $shall_pass_errors[_wsl__("Username is not valid!", 'wordpress-social-login')] = true; } if (!$request_user_login_validate) { $shall_pass = false; $shall_pass_errors[_wsl__("Username is not valid!", 'wordpress-social-login')] = true; } if ($request_user_login_exists) { $shall_pass = false; $shall_pass_errors[_wsl__("That Username is already registered!", 'wordpress-social-login')] = true; } } if (!$shall_pass) { ?> <!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title><?php echo get_bloginfo('name'); ?> </title> <head> <style> html, body { height: 100%; margin: 0; padding: 0; } body { background: none repeat scroll 0 0 #f1f1f1; font-size: 14px; color: #444; font-family: "Open Sans",sans-serif; } hr { border-color: #eeeeee; border-style: none none solid; border-width: 0 0 1px; margin: 2px 0 0; } h4 { font-size: 14px; margin-bottom: 10px; } #login { width: 585px; margin: auto; padding: 114px 0 0; } #login-panel { background: none repeat scroll 0 0 #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13); margin: 2em auto; box-sizing: border-box; display: inline-block; padding: 70px 0 15px; position: relative; text-align: center; width: 100%; } #avatar { margin-left: 213px; top: -82px; padding: 4px; position: absolute; } #avatar img { background: none repeat scroll 0 0 #fff; border: 3px solid #f1f1f1; border-radius: 75px !important; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13); height: 145px; width: 145px; } #welcome { margin: 15px 20px 15px; } #idp-icon { position: absolute; margin-top: 2px; margin-left: -19px; } #login-form{ margin: 0; padding: 0; } .button-primary { background-color: #21759b; background-image: linear-gradient(to bottom, #2a95c5, #21759b); border-color: #21759b #21759b #1e6a8d; border-radius: 3px; border-style: solid; border-width: 1px; box-shadow: 0 1px 0 rgba(120, 200, 230, 0.5) inset; box-sizing: border-box; color: #fff; cursor: pointer; display: inline-block; float: none; font-size: 13px; height: 32px; line-height: 23px; margin: 0; padding: 0 10px 1px; text-decoration: none; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.1); white-space: nowrap; } button-primary:focus, .button-primary:hover{ background:#1e8cbe; border-color:#0074a2; -webkit-box-shadow:inset 0 1px 0 rgba(120,200,230,.6); box-shadow:inset 0 1px 0 rgba(120,200,230,.6); color:#fff } input[type="text"]{ border: 1px solid #e5e5e5; box-shadow: 1px 1px 2px rgba(200, 200, 200, 0.2) inset; color: #555; font-size: 17px; height: 30px; line-height: 1; margin-bottom: 16px; margin-right: 6px; margin-top: 2px; outline: 0 none; padding: 3px; width: 99%; } input[type="text"]:focus{ border-color:#5b9dd9; -webkit-box-shadow:0 0 2px rgba(30,140,190,.8); box-shadow:0 0 2px rgba(30,140,190,.8) } input[type="submit"]{ float:right; } label{ color:#777; font-size:14px; cursor:pointer; vertical-align:middle; text-align: left; } table { width:485px; margin-left:auto; margin-right:auto; } table p{ margin-top:0; margin-bottom:0; } #mapping-complete-info { } #error { background-color: #fff; border: 1px solid #dd3d36; border-left: 4px solid #dd3d36; box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1); margin: 0 21px; margin: 0; margin-bottom:8px; padding: 12px; text-align: left; } .back-to-options { float: left; margin: 7px 0px; } .back-to-home { font-size: 12px; margin-top: -18px; } .back-to-home a { color: #999; text-decoration: none; } </style> <script> function init() { if( document.getElementById('user_login') ) document.getElementById('user_login').focus() if( document.getElementById('user_email') ) document.getElementById('user_email').focus() } </script> </head> <body onload="init();"> <div id="login"> <div id="login-panel"> <div id="avatar"> <img src="<?php echo $hybridauth_user_avatar; ?> "> </div> <div id="welcome"> <p> <?php printf(_wsl__("Hi %s, you're one step away from completing your account.", 'wordpress-social-login'), htmlentities($hybridauth_user_profile->displayName)); ?> </p> <p> <?php _wsl_e("Please, fill in your information in the form below to continue", 'wordpress-social-login'); ?> . </p> </div> <form method="post" action="<?php echo site_url('wp-login.php', 'login_post'); ?> " id="login-form"> <table id="mapping-complete-info" border="0"> <tr> <td> <?php if (isset($_REQUEST["bouncer_profile_completion"]) && $shall_pass_errors) { echo '<div id="error">'; foreach ($shall_pass_errors as $k => $v) { ?> <p><?php echo $k; ?> </p><?php } echo '</div>'; } ?> </td> </tr> <tr> <td valign="bottom" width="50%" style="text-align:left;"> <?php if (get_option('wsl_settings_bouncer_profile_completion_change_username') == 1) { ?> <p> <label for="user_login"><?php _wsl_e("Username", 'wordpress-social-login'); ?> <br><input type="text" name="user_login" id="user_login" class="input" value="<?php echo $request_user_login; ?> " size="25" /></label> </p> <?php } if (get_option('wsl_settings_bouncer_profile_completion_require_email') == 1) { ?> <p> <label for="user_email"><?php _wsl_e("E-mail", 'wordpress-social-login'); ?> <br><input type="text" name="user_email" id="user_email" class="input" value="<?php echo $request_user_email; ?> " size="25" /></label> </p> <?php } ?> <input type="submit" value="<?php _wsl_e("Continue", 'wordpress-social-login'); ?> " class="button-primary" > </td> </tr> </table> <input type="hidden" id="redirect_to" name="redirect_to" value="<?php echo $redirect_to; ?> "> <input type="hidden" id="provider" name="provider" value="<?php echo $provider; ?> "> <input type="hidden" id="action" name="action" value="wordpress_social_profile_completion"> <input type="hidden" id="bouncer_profile_completion" name="bouncer_profile_completion" value="1"> </form> </div> <p class="back-to-home"> <a href="<?php echo site_url(); ?> ">← <?php printf(_wsl__("Back to %s", 'wordpress-social-login'), get_bloginfo('name')); ?> </a> </p> </div> <?php // Development mode on? if (get_option('wsl_settings_development_mode_enabled')) { wsl_display_dev_mode_debugging_area(); } ?> </body> </html> <?php die; } return array($shall_pass, $request_user_login, $request_user_email); }
function wsl_component_users_delete_social_profiles() { // If action eq delete WSL user profiles if (isset($_REQUEST['delete']) && isset($_REQUEST['_wpnonce']) && wp_verify_nonce($_REQUEST['_wpnonce'])) { $uid = (int) $_REQUEST['delete']; $user_data = get_userdata($uid); if ($user_data) { wsl_delete_stored_hybridauth_user_data($uid); ?> <div class="fade updated" style="margin: 0px 0px 10px;"> <p> <?php echo sprintf(_wsl__("WSL user ID #%d: <b>%s</b> profiles and contacts has been deleted. Note that the associated WordPress user wasn't deleted", 'wordpress-social-login'), $uid, $user_data->user_login); ?> . </p> </div> <?php } } }
function wsl_component_tools_do_diagnostics() { ?> <style> table td, table th { border: 1px solid #DDDDDD; } table th label { font-weight: bold; } </style> <div class="metabox-holder columns-2" id="post-body"> <div class="stuffbox"> <h3> <label><?php _wsl_e("WordPress Social Login Diagnostics", 'wordpress-social-login'); ?> </label> </h3> <div class="inside"> <br /> <table class="wp-list-table widefat"> <?php $test = version_compare(PHP_VERSION, '5.2.0', '>='); // $test = 0; ?> <tr> <th width="200"> <label>PHP Version</label> </th> <td> <p>PHP >= 5.2.0 installed.</p> <?php if (!$test) { ?> <div class="fade error" style="margin: 20px 0;"> <p><b>Error</b>: An old version of PHP is installed.</p> <p>The solution is to make a trouble ticket to your web host and request them to upgrade to newer version of PHP.</p> </div> <?php } ?> </td> <td width="60"> <?php if ($test) { echo "<b style='color:green;'>OK!</b>"; } else { echo "<b style='color:red;'>FAIL!</b>"; } ?> </td> </tr> <?php $test = isset($_SESSION["wsl::plugin"]) && $_SESSION["wsl::plugin"]; // $test = 0; ?> <tr> <th width="200"> <label>PHP Sessions</label> </th> <td> <p>PHP/Session must be enabled and working.</p> <?php if (!$test) { ?> <div class="fade error" style="margin: 20px 0;"> <p><b>Error</b>: PHP Sessions are not working as expected.</p> <p> This error may occur for many reasons: </p> <p> 1. PHP session are either disabled, renamed or there is files permissions issues. </p> <p> 2. When using a reverse proxy like Varnish or a caching engine that might strip cookies. On this case, WSL will requires these two urls to be white-listed: </p> <div style="background-color: #FFFFE0;border:1px solid #E6DB55; border-radius: 3px;padding: 10px;margin:2px;"> <?php echo '<a href="' . site_url('wp-login.php', 'login_post') . '" target="_blank">' . site_url('wp-login.php', 'login_post') . '</a>'; echo '<br />'; echo '<a href="' . WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL . '" target="_blank">' . WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL . '</a>'; ?> </div> </div> <?php } else { ?> <hr /> <h4>Notes:</h4> <p> 1. If you're hosting your website on <b>WP Engine</b>, refer this topic: <a href="https://wordpress.org/support/topic/500-internal-server-error-when-redirecting" target="_blank">https://wordpress.org/support/topic/500-internal-server-error-when-redirecting</a> </p> <p>2. In case you're using a reverse proxy like Varnish or a caching engine that might strip cookies, WSL will requires these two urls to be white-listed:</p> <div style="background-color: #FFFFE0;border:1px solid #E6DB55; border-radius: 3px;padding: 10px;margin:2px;"> <?php echo '<a href="' . site_url('wp-login.php', 'login_post') . '" target="_blank">' . site_url('wp-login.php', 'login_post') . '</a>'; echo '<br />'; echo '<a href="' . WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL . '" target="_blank">' . WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL . '</a>'; ?> </div> <?php } ?> </td> <td> <?php if ($test) { echo "<b style='color:green;'>OK!</b>"; } else { echo "<b style='color:red;'>FAIL!</b>"; } ?> </td> </tr> <?php $test = false; if (function_exists('curl_init')) { $curl_version = curl_version(); if ($curl_version['features'] & CURL_VERSION_SSL) { $test = true; } } // $test = 0; ?> <tr> <th width="200"> <label>PHP CURL/SSL Extension</label> </th> <td> <p>PHP CURL extension with SSL must be enabled and working.</p> <?php if (!$test) { ?> <div class="fade error" style="margin: 20px 0;"> <p><b>Error</b>: CURL library is either not installed or SSL is not enabled.</p> <p>The solution is to make a trouble ticket to your web host and request them to enable the PHP CURL.</p> </div> <?php } ?> </td> <td> <?php if ($test) { echo "<b style='color:green;'>OK!</b>"; } else { echo "<b style='color:red;'>FAIL!</b>"; } ?> </td> </tr> <?php $test = !ini_get('register_globals') ? true : false; // $test = 0; ?> <tr> <th width="200"> <label>PHP Register Globals</label> </th> <td> <p>PHP Register Globals must be OFF.</p> <?php if (!$test) { ?> <div class="fade error" style="margin: 20px 0;"> <p><b>Error</b>: REGISTER_GLOBALS are On.</p> <p>This will prevent WSL from working properly and will result on an infinite loop on the authentication page.</p> <p>The solution is to make a trouble ticket with your web host to disable it, Or, if you have a dedicated server and you know what are you doing then edit php.ini file and turn it Off.</p> </div> <?php } ?> </td> <td> <?php if ($test) { echo "<b style='color:green;'>OK!</b>"; } else { echo "<b style='color:red;'>FAIL!</b>"; } ?> </td> </tr> <!-- this should keep Mika happy --> <tr> <th width="200"> <label>WSL end-points</label> </th> <td> <p>Check if WSL end-points urls are reachable.</p> <div id="end_points_warn" class="fade error" style="margin: 20px 0;display:none;"> <p><b>Error</b>: Your web server returned <span id="end_points_error"></span> when checking WSL end-points.</p> <p>This issue usually happen when :</p> <p>1. Your web host uses <code>mod_security</code> to block requests containing URLs (eg. hosts like HostGator, GoDaddy and The Planet). On this case, you should contact your provider to have WSL end-points urls white-listed.</p> <p>2. There is a <code>.htaccess</code> file that prevent direct access to the WordPress plugins directory.</p> <p>In any case, WSL requires this url to be white-listed:</p> <div style="background-color: #FFFFE0;border:1px solid #E6DB55; border-radius: 3px;padding: 10px;margin:2px;"> <?php echo '<a href="' . WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL . '" target="_blank">' . WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL . '</a>'; ?> </div> </div> <div id="end_points_note" style="margin: 20px 0;"> <hr /> <p><b>Note</b>: In case you're using <code>mod_security</code> to block requests containing URLs or a <code>.htaccess</code> file to protect the WordPress plugins directory, WSL will requires this url to be white-listed:</p> <div style="background-color: #FFFFE0;border:1px solid #E6DB55; border-radius: 3px;padding: 10px;margin:2px;"> <?php echo '<a href="' . WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL . '" target="_blank">' . WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL . '</a>'; ?> </div> </div> <p>You may double-check this test manually by clicking this <a href="<?php echo WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL; ?> ?test=http://example.com" target="_blank">direct link</a>.</p> </td> <td width="60"> <span id="end_points">testing..</span> <script> jQuery(document).ready(function($) { jQuery.ajax({ url: '<?php echo WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL; ?> ', data: 'url=http://example.com', success: function () { jQuery('#end_points').html( '<b style="color:green;">OK!</b>' ); }, error: function (xhr, ajaxOptions, thrownError) { // console.log( xhr ); jQuery('#end_points_error').html( '"<b style="color:red;">' + xhr.status + ' ' + xhr.statusText + '</b>"' ); jQuery('#end_points').html( '<b style="color:red;">FAIL!</b>' ); jQuery('#end_points_warn').show(); jQuery('#end_points_note').hide(); } }); }); </script> </td> </tr> <?php global $wpdb; $db_check_profiles = $wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}wslusersprofiles'") === $wpdb->prefix . 'wslusersprofiles' ? 1 : 0; $db_check_contacts = $wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}wsluserscontacts'") === $wpdb->prefix . 'wsluserscontacts' ? 1 : 0; $test = $db_check_profiles && $db_check_contacts ? true : false; ?> <tr> <th width="200"> <label>WSL database tables</label> </th> <td> <p>Check if WSL database tables (<code>wslusersprofiles</code> and <code>wsluserscontacts</code>) exist.</p> <?php if (!$test) { ?> <div class="fade error" style="margin: 20px 0;"> <p><b>Error:</b> One or more of WordPress Social Login tables do not exist.</p> <p>This may prevent this plugin form working correctly. To fix this, navigate to <b>Tools</b> tab then <b><a href="options-general.php?page=wordpress-social-login&wslp=tools#repair-tables">Repair WSL tables</a></b>.</p> </div> <?php } ?> </td> <td width="60"> <?php if ($test) { echo "<b style='color:green;'>OK!</b>"; } else { echo "<b style='color:red;'>FAIL!</b>"; } ?> </td> </tr> <?php $test = class_exists('Hybrid_Auth', false) ? false : true; ?> <tr> <th width="200"> <label>Hybridauth Library</label> </th> <td> <p>Check if the Hybridauth Library is auto-loaded by another plugin.</p> <?php if (!$test) { ?> <div class="fade error" style="margin: 20px 0;"> <p>Hybridauth Library is auto-included by another plugin.</p> <p>This is not critical but it may prevent WSL from working.</p> <p>Please, inform the developer of that plugin not to auto-include the file below and to use Hybridauth Library only when required.</p> <div style="background-color: #FFFFE0;border:1px solid #E6DB55; border-radius: 3px;padding: 10px;margin:2px;"> <?php try { $reflector = new ReflectionClass('Hybrid_Auth'); echo $reflector->getFileName(); } catch (Exception $e) { } ?> </div> </div> <?php } ?> </td> <td> <?php if ($test) { echo "<b style='color:green;'>OK!</b>"; } else { echo "<b style='color:orange;'>PASS</b>"; } ?> </td> </tr> <?php $test = class_exists('OAuthConsumer', false) ? false : true; ?> <tr> <th width="200"> <label>OAUTH Library</label> </th> <td> <p>Check if OAUTH Library is auto-loaded by another plugin.</p> <?php if (!$test) { ?> <div class="fade error" style="margin: 20px 0;"> <p>OAUTH Library is auto-included by another plugin.</p> <p>This is not critical but it may prevent Twitter, LinkedIn and few other providers from working.</p> <p>Please, inform the developer of that plugin not to auto-include the file below and to use OAUTH Library only when required.</p> <div style="background-color: #FFFFE0;border:1px solid #E6DB55; border-radius: 3px;padding: 10px;margin:2px;"> <?php try { $reflector = new ReflectionClass('OAuthConsumer'); echo $reflector->getFileName(); } catch (Exception $e) { } ?> </div> </div> <?php } ?> </td> <td> <?php if ($test) { echo "<b style='color:green;'>OK!</b>"; } else { echo "<b style='color:orange;'>PASS</b>"; } ?> </td> </tr> <?php $test = class_exists('BaseFacebook', false) ? false : true; ?> <tr> <th width="200"> <label>Facebook SDK</label> </th> <td> <p>Check if Facebook SDK is auto-loaded by another plugin.</p> <?php if (!$test) { ?> <div class="fade error" style="margin: 20px 0;"> <p><b>Error:</b> Facebook SDK is auto-included by another plugin.</p> <p>This will prevent Facebook from working.</p> <p>Please, inform the developer of that plugin not to auto-include the file below and to use Facebook SDK only when required.</p> <div style="background-color: #FFFFE0;border:1px solid #E6DB55; border-radius: 3px;padding: 10px;margin:2px;"> <?php try { $reflector = new ReflectionClass('BaseFacebook'); echo $reflector->getFileName(); } catch (Exception $e) { } ?> </div> </div> <?php } ?> </td> <td> <?php if ($test) { echo "<b style='color:green;'>OK!</b>"; } else { echo "<b style='color:red;'>FAIL!</b>"; } ?> </td> </tr> <?php $test = class_exists('LightOpenID', false) ? false : true; ?> <tr> <th width="200"> <label>Class LightOpenID</label> </th> <td> <p>Check if the LightOpenID Class is auto-loaded by another plugin.</p> <?php if (!$test) { ?> <div class="fade error" style="margin: 20px 0;"> <p>Class LightOpenID is auto-included by another plugin.</p> <p>This is not critical but it may prevent Yahoo, Steam, and few other providers from working.</p> <p>Please, inform the developer of that plugin not to auto-include the file below and to use Class LightOpenID only when required.</p> <div style="background-color: #FFFFE0;border:1px solid #E6DB55; border-radius: 3px;padding: 10px;margin:2px;"> <?php try { $reflector = new ReflectionClass('LightOpenID'); echo $reflector->getFileName(); } catch (Exception $e) { } ?> </div> </div> <?php } ?> </td> <td> <?php if ($test) { echo "<b style='color:green;'>OK!</b>"; } else { echo "<b style='color:orange;'>PASS</b>"; } ?> </td> </tr> <?php $curl = ''; $test = true; if (!class_exists('Hybrid_Auth', false)) { include_once WORDPRESS_SOCIAL_LOGIN_ABS_PATH . "/hybridauth/Hybrid/Auth.php"; $curl = Hybrid_Auth::getCurrentUrl(); } $headers = array('HTTP_VIA', 'HTTP_X_FORWARDED_FOR', 'HTTP_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_FORWARDED', 'HTTP_CLIENT_IP', 'HTTP_FORWARDED_FOR_IP', 'VIA', 'X_FORWARDED_FOR', 'FORWARDED_FOR', 'X_FORWARDED', 'FORWARDED', 'CLIENT_IP', 'FORWARDED_FOR_IP', 'HTTP_PROXY_CONNECTION'); foreach ($headers as $v) { if (isset($_SERVER[$v])) { $test = true; } } ?> <tr> <th width="200"> <label>HTTP Proxies</label> </th> <td> <p>Check for proxified urls.</p> <?php if (!$test) { ?> <div class="fade error" style="margin: 20px 0;"> <p>WSL has detected that you are using a proxy in your website. The URL shown below should match the URL on your browser address bar.</p> <div style="background-color: #FFFFE0;border:1px solid #E6DB55; border-radius: 3px;padding: 10px;margin:2px;"> <?php echo $curl; ?> </div> </div> <?php } ?> </td> <td> <?php if ($test) { echo "<b style='color:green;'>OK!</b>"; } else { echo "<b style='color:orange;'>PASS</b>"; } ?> </td> </tr> <?php $test = !stristr(plugins_url(), site_url()) ? false : true; ?> <tr> <th width="200"> <label>WordPress functions</label> </th> <td> <p>Check for WordPress directories functions.</p> <?php if (!$test) { ?> <hr /> <p><code>plugins_url()</code> is not returning an expected result : <?php echo plugins_url(); ?> </p> <?php } ?> </td> <td> <?php if ($test) { echo "<b style='color:green;'>OK!</b>"; } else { echo "<b style='color:orange;'>PASS</b>"; } ?> </td> </tr> <?php $test = true; $used = array(); $depreciated = array('wsl_hook_process_login_alter_userdata', 'wsl_hook_process_login_before_insert_user', 'wsl_hook_process_login_after_create_wp_user', 'wsl_hook_process_login_before_set_auth_cookie', 'wsl_hook_process_login_before_redirect', 'wsl_render_login_form_start', 'wsl_alter_hook_provider_icon_markup', 'wsl_render_login_form_alter_provider_icon_markup', 'wsl_render_login_form_end'); foreach ($depreciated as $v) { if (has_filter($v) || has_action($v)) { $test = false; $used[] = $v; } } ?> <tr> <th width="200"> <label>WSL depreciated hooks</label> </th> <td> <p>Check for depreciated WSL actions and filters in use.</p> <?php if (!$test) { ?> <div class="fade error" style="margin: 20px 0;"> <p>WSL has detected that you are using depreciated WSL: <code><?php echo implode('</code>, <code>', $used); ?> </code></p> <p>Please update the WSL hooks you were using accordingly to the new developer API at <a href="http://miled.github.io/wordpress-social-login/documentation.html" target="_blank">http://miled.github.io/wordpress-social-login/documentation.html</a></p> </div> <?php } ?> <p> Note: this test is not reliable 100% as we simply match the depreciated hooks against <code>has_filter</code> and <code>has_action</code>.</p> </td> <td> <?php if ($test) { echo "<b style='color:green;'>OK!</b>"; } else { echo "<b style='color:orange;'>PASS</b>"; } ?> </td> </tr> <?php $itsec_tweaks = get_option('itsec_tweaks'); $test = $itsec_tweaks && $itsec_tweaks['long_url_strings'] ? false : true; ?> <tr> <th width="200"> <label>iThemes Security</label> </th> <td> <p>Check if 'Prevent long URL strings' option is enabled.</p> <?php if (!$test) { ?> <div class="fade error" style="margin: 20px 0;"> <p><b>Error:</b> 'Prevent long URL strings' option is in enabled.</p> <p>This may prevent Facebook and few other providers from working.</p> </div> <?php } ?> </td> <td> <?php if ($test) { echo "<b style='color:green;'>OK!</b>"; } else { echo "<b style='color:red;'>FAIL!</b>"; } ?> </td> </tr> <?php /** * Check twitter timestamp * * Thanks much Joe for the cool idea * https://wordpress.org/plugins/wp-to-twitter/ */ $test = true; $error = ''; $hint = ''; $server_time = date(DATE_COOKIE); $response = wp_remote_get("https://api.twitter.com/1.1/help/test.json", array('timeout' => 2, 'redirection' => 1)); if (is_wp_error($response)) { $test = false; $error = __("There was an error querying Twitter's servers", 'wordpress-social-login'); } else { if (time() < strtotime($response['headers']['date']) - 300 || time() > strtotime($response['headers']['date']) + 300) { $test = false; $error = _wsl__("Your web server date is set incorrectly. This may prevent Twitter and LinkedIn and few other providers from working", 'wordpress-social-login'); $hint = sprintf(_wsl__("Please check if your web server time is correct: <code>%s</code>", 'wordpress-social-login'), $server_time); } } ?> <tr> <th width="200"> <label>Server Timestamp</label> </th> <td> <p>Check if your web server clock is in sync.</p> <?php if (!$test) { ?> <div class="fade error" style="margin: 20px 0;"> <p><b>Error:</b> <?php echo $error; ?> .</p> <?php if ($hint) { echo '<p>' . $hint . '.</p>'; } ?> </div> <?php } ?> </td> <td> <?php if ($test) { echo "<b style='color:green;'>OK!</b>"; } else { echo "<b style='color:orange;'>PASS</b>"; } ?> </td> </tr> </table> <br /> <hr /> <a class="button-secondary" href="options-general.php?page=wordpress-social-login&wslp=tools">← <?php _wsl_e("Back to Tools", 'wordpress-social-login'); ?> </a> </div> </div> </div> <?php }
/** * Generate the HTML content of WSL Widget * * Note: * WSL shortcode arguments are still experimental and might change in future versions. * * [wordpress_social_login * auth_mode="login" * caption="Connect with" * enable_providers="facebook|google" * restrict_content="wsl_user_logged_in" * assets_base_url="http://example.com/wp-content/uploads/2022/01/" * ] * * Overall, WSL widget work with these simple rules : * 1. Shortcode arguments rule over the defaults * 2. Filters hooks rule over shortcode arguments * 3. Bouncer rules over everything */ function wsl_render_auth_widget($args = array()) { $auth_mode = isset($args['mode']) && $args['mode'] ? $args['mode'] : 'login'; // validate auth-mode if (!in_array($auth_mode, array('login', 'link', 'test'))) { return; } // auth-mode eq 'login' => display wsl widget only for NON logged in users // > this is the default mode of wsl widget. if ($auth_mode == 'login' && is_user_logged_in()) { return; } // auth-mode eq 'link' => display wsl widget only for LOGGED IN users // > this will allows users to manually link other social network accounts to their WordPress account if ($auth_mode == 'link' && !is_user_logged_in()) { return; } // auth-mode eq 'test' => display wsl widget only for LOGGED IN users only on dashboard // > used in Authentication Playground on WSL admin dashboard if ($auth_mode == 'test' && !is_user_logged_in() && !is_admin()) { return; } // Bouncer :: Allow authentication? if (get_option('wsl_settings_bouncer_authentication_enabled') == 2) { return; } // HOOKABLE: This action runs just before generating the WSL Widget. do_action('wsl_render_auth_widget_start'); global $WORDPRESS_SOCIAL_LOGIN_PROVIDERS_CONFIG; ob_start(); // Icon set. If eq 'none', we show text instead $social_icon_set = get_option('wsl_settings_social_icon_set'); // wpzoom icons set, is shown by default if (empty($social_icon_set)) { $social_icon_set = "wpzoom/"; } $assets_base_url = WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL . 'assets/img/32x32/' . $social_icon_set . '/'; $assets_base_url = isset($args['assets_base_url']) && $args['assets_base_url'] ? $args['assets_base_url'] : $assets_base_url; // HOOKABLE: $assets_base_url = apply_filters('wsl_render_auth_widget_alter_assets_base_url', $assets_base_url); // get the current page url, which we will use to redirect the user to, // unless Widget::Force redirection is set to 'yes', then this will be ignored and Widget::Redirect URL will be used instead $redirect_to = wsl_get_current_url(); // Use the provided redirect_to if it is given and this is the login page. if (in_array($GLOBALS["pagenow"], array("wp-login.php", "wp-register.php")) && !empty($_REQUEST["redirect_to"])) { $redirect_to = $_REQUEST["redirect_to"]; } // build the authentication url which will call for wsl_process_login() : action=wordpress_social_authenticate $authenticate_base_url = site_url('wp-login.php', 'login_post') . (strpos(site_url('wp-login.php', 'login_post'), '?') ? '&' : '?') . "action=wordpress_social_authenticate&mode=login&"; // if not in mode login, we overwrite the auth base url // > admin auth playground if ($auth_mode == 'test') { $authenticate_base_url = home_url() . "/?action=wordpress_social_authenticate&mode=test&"; } elseif ($auth_mode == 'link') { $authenticate_base_url = home_url() . "/?action=wordpress_social_authenticate&mode=link&"; } // Connect with caption $connect_with_label = _wsl__(get_option('wsl_settings_connect_with_label'), 'wordpress-social-login'); $connect_with_label = isset($args['caption']) ? $args['caption'] : $connect_with_label; // HOOKABLE: $connect_with_label = apply_filters('wsl_render_auth_widget_alter_connect_with_label', $connect_with_label); ?> <!-- wsl_render_auth_widget WordPress Social Login <?php echo wsl_get_version(); ?> . http://wordpress.org/plugins/wordpress-social-login/ --> <?php // Widget::Custom CSS $widget_css = get_option('wsl_settings_authentication_widget_css'); // HOOKABLE: $widget_css = apply_filters('wsl_render_auth_widget_alter_widget_css', $widget_css, $redirect_to); // show the custom widget css if not empty if (!empty($widget_css)) { ?> <style type="text/css"> <?php echo preg_replace(array('%/\\*(?:(?!\\*/).)*\\*/%s', '/\\s{2,}/', "/\\s*([;{}])[\r\n\t\\s]/", '/\\s*;\\s*/', '/\\s*{\\s*/', '/;?\\s*}\\s*/'), array('', ' ', '$1', ';', '{', '}'), $widget_css); ?> </style> <?php } ?> <div class="wp-social-login-widget"> <div class="wp-social-login-connect-with"><?php echo $connect_with_label; ?> </div> <div class="wp-social-login-provider-list"> <?php // Widget::Authentication display $wsl_settings_use_popup = get_option('wsl_settings_use_popup'); // if a user is visiting using a mobile device, WSL will fall back to more in page $wsl_settings_use_popup = function_exists('wp_is_mobile') ? wp_is_mobile() ? 2 : $wsl_settings_use_popup : $wsl_settings_use_popup; $no_idp_used = true; // display provider icons foreach ($WORDPRESS_SOCIAL_LOGIN_PROVIDERS_CONFIG as $item) { $provider_id = isset($item["provider_id"]) ? $item["provider_id"] : ''; $provider_name = isset($item["provider_name"]) ? $item["provider_name"] : ''; // provider enabled? if (get_option('wsl_settings_' . $provider_id . '_enabled')) { // restrict the enabled providers list if (isset($args['enable_providers'])) { $enable_providers = explode('|', $args['enable_providers']); // might add a couple of pico seconds if (!in_array(strtolower($provider_id), $enable_providers)) { continue; } } // build authentication url $authenticate_url = $authenticate_base_url . "provider=" . $provider_id . "&redirect_to=" . urlencode($redirect_to); // http://codex.wordpress.org/Function_Reference/esc_url $authenticate_url = esc_url($authenticate_url); // in case, Widget::Authentication display is set to 'popup', then we overwrite 'authenticate_url' // > /assets/js/connect.js will take care of the rest if ($wsl_settings_use_popup == 1 && $auth_mode != 'test') { $authenticate_url = "javascript:void(0);"; } // HOOKABLE: allow user to rebuilt the auth url $authenticate_url = apply_filters('wsl_render_auth_widget_alter_authenticate_url', $authenticate_url, $provider_id, $auth_mode, $redirect_to, $wsl_settings_use_popup); // HOOKABLE: allow use of other icon sets $provider_icon_markup = apply_filters('wsl_render_auth_widget_alter_provider_icon_markup', $provider_id, $provider_name, $authenticate_url); if ($provider_icon_markup != $provider_id) { echo $provider_icon_markup; } else { ?> <a rel="nofollow" href="<?php echo $authenticate_url; ?> " title="<?php echo sprintf(_wsl__("%s", 'wordpress-social-login'), $provider_name); ?> " class="wp-social-login-provider wp-social-login-provider-<?php echo strtolower($provider_id); ?> " data-provider="<?php echo $provider_id; ?> "> <?php if ($social_icon_set == 'none') { echo apply_filters('wsl_render_auth_widget_alter_provider_name', '' . $provider_name); } else { ?> <img alt="<?php echo $provider_name; ?> " title="<?php echo sprintf(_wsl__("%s", 'wordpress-social-login'), $provider_name); ?> " src="<?php echo $assets_base_url . strtolower($provider_id) . '.png'; ?> " /><?php } ?> </a> <?php } $no_idp_used = false; } } ?> <?php // no provider enabled? if ($no_idp_used) { ?> <p style="background-color: #FFFFE0;border:1px solid #E6DB55;padding:5px;"> <?php _wsl_e('<strong>WordPress Social Login is not configured yet</strong>.<br />Please navigate to <strong>Settings > WP Social Login</strong> to configure this plugin.<br />For more information, refer to the <a rel="nofollow" href="http://miled.github.io/wordpress-social-login">online user guide</a>.', 'wordpress-social-login'); ?> . </p> <style>#wp-social-login-connect-with{display:none;}</style> <?php } ?> </div> <div class="wp-social-login-widget-clearing"></div> </div> <?php // provide popup url for hybridauth callback if ($wsl_settings_use_popup == 1) { ?> <input type="hidden" id="wsl_popup_base_url" value="<?php echo esc_url($authenticate_base_url); ?> " /> <input type="hidden" id="wsl_login_form_uri" value="<?php echo esc_url(site_url('wp-login.php', 'login_post')); ?> " /> <?php } // HOOKABLE: This action runs just after generating the WSL Widget. do_action('wsl_render_auth_widget_end'); ?> <!-- wsl_render_auth_widget --> <?php // Display WSL debugging area bellow the widget. // wsl_display_dev_mode_debugging_area(); // ! keep this line commented unless you know what you are doing :) return ob_get_clean(); }
/** * Check and upgrade compatibilities from old WSL versions */ function wsl_update_compatibilities() { delete_option('wsl_settings_development_mode_enabled'); delete_option('wsl_settings_debug_mode_enabled'); update_option('wsl_settings_welcome_panel_enabled', 1); if (!get_option('wsl_settings_redirect_url')) { update_option('wsl_settings_redirect_url', home_url()); } if (!get_option('wsl_settings_force_redirect_url')) { update_option('wsl_settings_force_redirect_url', 2); } if (!get_option('wsl_settings_connect_with_label')) { update_option('wsl_settings_connect_with_label', _wsl__("Connect with:", 'wordpress-social-login')); } if (!get_option('wsl_settings_users_avatars')) { update_option('wsl_settings_users_avatars', 1); } if (!get_option('wsl_settings_use_popup')) { update_option('wsl_settings_use_popup', 2); } if (!get_option('wsl_settings_widget_display')) { update_option('wsl_settings_widget_display', 1); } if (!get_option('wsl_settings_authentication_widget_css')) { update_option('wsl_settings_authentication_widget_css', ".wp-social-login-connect-with {}\n.wp-social-login-provider-list {}\n.wp-social-login-provider-list a {}\n.wp-social-login-provider-list img {}\n.wsl_connect_with_provider {}"); } # bouncer settings if (!get_option('wsl_settings_bouncer_registration_enabled')) { update_option('wsl_settings_bouncer_registration_enabled', 1); } if (!get_option('wsl_settings_bouncer_authentication_enabled')) { update_option('wsl_settings_bouncer_authentication_enabled', 1); } if (!get_option('wsl_settings_bouncer_accounts_linking_enabled')) { update_option('wsl_settings_bouncer_accounts_linking_enabled', 1); } if (!get_option('wsl_settings_bouncer_profile_completion_require_email')) { update_option('wsl_settings_bouncer_profile_completion_require_email', 2); } if (!get_option('wsl_settings_bouncer_profile_completion_change_username')) { update_option('wsl_settings_bouncer_profile_completion_change_username', 2); } if (!get_option('wsl_settings_bouncer_profile_completion_hook_extra_fields')) { update_option('wsl_settings_bouncer_profile_completion_hook_extra_fields', 2); } if (!get_option('wsl_settings_bouncer_new_users_moderation_level')) { update_option('wsl_settings_bouncer_new_users_moderation_level', 1); } if (!get_option('wsl_settings_bouncer_new_users_membership_default_role')) { update_option('wsl_settings_bouncer_new_users_membership_default_role', "default"); } if (!get_option('wsl_settings_bouncer_new_users_restrict_domain_enabled')) { update_option('wsl_settings_bouncer_new_users_restrict_domain_enabled', 2); } if (!get_option('wsl_settings_bouncer_new_users_restrict_domain_text_bounce')) { update_option('wsl_settings_bouncer_new_users_restrict_domain_text_bounce', _wsl__("<strong>This website is restricted to invited readers only.</strong><p>It doesn't look like you have been invited to access this site. If you think this is a mistake, you might want to contact the website owner and request an invitation.<p>", 'wordpress-social-login')); } if (!get_option('wsl_settings_bouncer_new_users_restrict_email_enabled')) { update_option('wsl_settings_bouncer_new_users_restrict_email_enabled', 2); } if (!get_option('wsl_settings_bouncer_new_users_restrict_email_text_bounce')) { update_option('wsl_settings_bouncer_new_users_restrict_email_text_bounce', _wsl__("<strong>This website is restricted to invited readers only.</strong><p>It doesn't look like you have been invited to access this site. If you think this is a mistake, you might want to contact the website owner and request an invitation.<p>", 'wordpress-social-login')); } if (!get_option('wsl_settings_bouncer_new_users_restrict_profile_enabled')) { update_option('wsl_settings_bouncer_new_users_restrict_profile_enabled', 2); } if (!get_option('wsl_settings_bouncer_new_users_restrict_profile_text_bounce')) { update_option('wsl_settings_bouncer_new_users_restrict_profile_text_bounce', _wsl__("<strong>This website is restricted to invited readers only.</strong><p>It doesn't look like you have been invited to access this site. If you think this is a mistake, you might want to contact the website owner and request an invitation.<p>", 'wordpress-social-login')); } # contacts import if (!get_option('wsl_settings_contacts_import_facebook')) { update_option('wsl_settings_contacts_import_facebook', 2); } if (!get_option('wsl_settings_contacts_import_google')) { update_option('wsl_settings_contacts_import_google', 2); } if (!get_option('wsl_settings_contacts_import_twitter')) { update_option('wsl_settings_contacts_import_twitter', 2); } if (!get_option('wsl_settings_contacts_import_live')) { update_option('wsl_settings_contacts_import_live', 2); } if (!get_option('wsl_settings_contacts_import_linkedin')) { update_option('wsl_settings_contacts_import_linkedin', 2); } if (!get_option('wsl_settings_buddypress_enable_mapping')) { update_option('wsl_settings_buddypress_enable_mapping', 2); } # buddypress profile mapping if (!get_option('wsl_settings_buddypress_xprofile_map')) { update_option('wsl_settings_buddypress_xprofile_map', ''); } # if no idp is enabled then we enable the default providers (facebook, google, twitter) global $WORDPRESS_SOCIAL_LOGIN_PROVIDERS_CONFIG; $nok = true; foreach ($WORDPRESS_SOCIAL_LOGIN_PROVIDERS_CONFIG as $item) { $provider_id = $item["provider_id"]; if (get_option('wsl_settings_' . $provider_id . '_enabled')) { $nok = false; } } if ($nok) { foreach ($WORDPRESS_SOCIAL_LOGIN_PROVIDERS_CONFIG as $item) { $provider_id = $item["provider_id"]; if (isset($item["default_network"]) && $item["default_network"]) { update_option('wsl_settings_' . $provider_id . '_enabled', 1); } } } global $wpdb; # migrate steam users id to id64. Prior to 2.2 $sql = "UPDATE {$wpdb->prefix}wslusersprofiles\n\t\tSET identifier = REPLACE( identifier, 'http://steamcommunity.com/openid/id/', '' )\n\t\tWHERE provider = 'Steam' AND identifier like 'http://steamcommunity.com/openid/id/%' "; $wpdb->query($sql); }
function wsl_process_login_new_users_gateway($provider, $redirect_to, $hybridauth_user_profile) { // HOOKABLE: do_action("wsl_process_login_new_users_gateway_start", $provider, $redirect_to, $hybridauth_user_profile); $assets_base_url = WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL . '/assets/img/16x16/'; // remove wsl widget remove_action('register_form', 'wsl_render_auth_widget_in_wp_register_form'); $hybridauth_user_email = sanitize_email($hybridauth_user_profile->email); $hybridauth_user_login = sanitize_user($hybridauth_user_profile->displayName, true); $hybridauth_user_avatar = $hybridauth_user_profile->photoURL; $hybridauth_user_website = $hybridauth_user_profile->webSiteURL; $hybridauth_user_link = $hybridauth_user_profile->profileURL; $hybridauth_user_login = trim(str_replace(array(' ', '.'), '_', $hybridauth_user_login)); $hybridauth_user_login = trim(str_replace('__', '_', $hybridauth_user_login)); $requested_user_email = isset($_REQUEST["user_email"]) ? trim($_REQUEST["user_email"]) : $hybridauth_user_email; $requested_user_login = isset($_REQUEST["user_login"]) ? trim($_REQUEST["user_login"]) : $hybridauth_user_login; $requested_user_email = apply_filters('wsl_new_users_gateway_alter_requested_email', $requested_user_email); $requested_user_login = apply_filters('wsl_new_users_gateway_alter_requested_login', $requested_user_login); $user_id = 0; $shall_pass = false; $bouncer_account_linking = false; $account_linking_errors = array(); $bouncer_profile_completion = false; $profile_completion_errors = array(); $linking_enabled = get_option('wsl_settings_bouncer_accounts_linking_enabled'); // $linking_enabled = 2; // overide linking_enabled if (isset($_REQUEST["bouncer_account_linking"])) { if ($linking_enabled == 2) { return wsl_process_login_render_notice_page(_wsl__("Not tonight.", 'wordpress-social-login')); } $bouncer_account_linking = true; $username = isset($_REQUEST["user_login"]) ? trim($_REQUEST["user_login"]) : ''; $password = isset($_REQUEST["user_password"]) ? trim($_REQUEST["user_password"]) : ''; # http://codex.wordpress.org/Function_Reference/wp_authenticate $user = wp_authenticate($username, $password); // WP_Error object? if (is_wp_error($user)) { // we give no useful hint. $account_linking_errors[] = sprintf(_wsl__('<strong>ERROR</strong>: Invalid username or incorrect password. <a href="%s">Lost your password</a>?', 'wordpress-social-login'), wp_lostpassword_url(home_url())); } elseif (is_a($user, 'WP_User')) { $user_id = $user->ID; $shall_pass = true; } } elseif (isset($_REQUEST["bouncer_profile_completion"])) { $require_email = get_option('wsl_settings_bouncer_profile_completion_require_email'); $change_username = get_option('wsl_settings_bouncer_profile_completion_change_username'); $extra_fields = get_option('wsl_settings_bouncer_profile_completion_hook_extra_fields'); // Bouncer::Profile Completion enabled? // > if not enabled we just let the user pass if ($require_email == 2 && $change_username == 2 && $extra_fields == 2) { $shall_pass = true; } else { $bouncer_profile_completion = true; /** * Code based on wpmu_validate_user_signup() * * Ref: http://codex.wordpress.org/Function_Reference/wpmu_validate_user_signup */ # {{{ validate usermail if ($require_email == 1) { if (empty($requested_user_email)) { $profile_completion_errors[] = _wsl__('<strong>ERROR</strong>: Please type your e-mail address.', 'wordpress-social-login'); } if (!is_email($requested_user_email)) { $profile_completion_errors[] = _wsl__('<strong>ERROR</strong>: Please enter a valid email address.', 'wordpress-social-login'); } if (wsl_wp_email_exists($requested_user_email)) { $profile_completion_errors[] = _wsl__('<strong>ERROR</strong>: Sorry, that email address is already used!', 'wordpress-social-login'); } } # }}} validate usermail # {{{ validate username (called login in wsl) if ($change_username == 1) { $illegal_names = array('www', 'web', 'root', 'admin', 'main', 'invite', 'administrator'); $illegal_names = apply_filters('wsl_new_users_gateway_alter_illegal_names', $illegal_names); if (in_array($requested_user_login, $illegal_names) == true) { $profile_completion_errors[] = _wsl__('<strong>ERROR</strong>: That username is not allowed.', 'wordpress-social-login'); } if (strlen($requested_user_login) < 4) { $profile_completion_errors[] = _wsl__('<strong>ERROR</strong>: Username must be at least 4 characters.', 'wordpress-social-login'); } if (strpos(' ' . $requested_user_login, '_') != false) { $profile_completion_errors[] = _wsl__('<strong>ERROR</strong>: Sorry, usernames may not contain the character “_”!', 'wordpress-social-login'); } if (preg_match('/^[0-9]*$/', $requested_user_login)) { $profile_completion_errors[] = _wsl__('<strong>ERROR</strong>: Sorry, usernames must have letters too!', 'wordpress-social-login'); } if (username_exists($requested_user_login)) { $profile_completion_errors[] = _wsl__('<strong>ERROR</strong>: Sorry, that username already exists!', 'wordpress-social-login'); } } # }}} validate username # ... well, that was a lot of sorries. # {{{ extra fields if ($extra_fields == 1) { $errors = new WP_Error(); $errors = apply_filters('registration_errors', $errors, $requested_user_login, $requested_user_email); if ($errors = $errors->get_error_messages()) { foreach ($errors as $error) { $profile_completion_errors[] = $error; } } } # }}} extra fields $profile_completion_errors = apply_filters('wsl_new_users_gateway_alter_profile_completion_errors', $profile_completion_errors); // all check? if (!$profile_completion_errors) { $shall_pass = true; } } } if ($shall_pass == false) { ?> <!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title><?php echo get_bloginfo('name'); ?> </title> <style type="text/css"> html, body { height: 100%; margin: 0; padding: 0; } body { background: none repeat scroll 0 0 #f1f1f1; font-size: 14px; color: #444; font-family: "Open Sans",sans-serif; } hr { border-color: #eeeeee; border-style: none none solid; border-width: 0 0 1px; margin: 2px 0 0; } h4 { font-size: 14px; margin-bottom: 10px; } #login { width: 616px; margin: auto; padding: 114px 0 0; } #login-panel { background: none repeat scroll 0 0 #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13); margin: 2em auto; box-sizing: border-box; display: inline-block; padding: 70px 0 15px; position: relative; text-align: center; width: 100%; } #avatar { margin-left: -76px; top: -80px; left: 50%; padding: 4px; position: absolute; } #avatar img { background: none repeat scroll 0 0 #fff; border: 3px solid #f1f1f1; border-radius: 75px !important; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13); height: 145px; width: 145px; } #welcome { height: 55px; margin: 15px 20px 35px; } #idp-icon { position: absolute; margin-top: 2px; margin-left: -19px; } #login-form{ margin: 0; padding: 0; } .button-primary { background-color: #21759b; background-image: linear-gradient(to bottom, #2a95c5, #21759b); border-color: #21759b #21759b #1e6a8d; border-radius: 3px; border-style: solid; border-width: 1px; box-shadow: 0 1px 0 rgba(120, 200, 230, 0.5) inset; box-sizing: border-box; color: #fff; cursor: pointer; display: inline-block; float: none; font-size: 12px; height: 36px; line-height: 23px; margin: 0; padding: 0 10px 1px; text-decoration: none; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.1); white-space: nowrap; } button-primary.focus, .button-primary:hover{ background:#1e8cbe; border-color:#0074a2; -webkit-box-shadow:inset 0 1px 0 rgba(120,200,230,.6); box-shadow:inset 0 1px 0 rgba(120,200,230,.6); color:#fff } input[type="text"]{ border: 1px solid #e5e5e5; box-shadow: 1px 1px 2px rgba(200, 200, 200, 0.2) inset; color: #555; font-size: 17px; height: 30px; line-height: 1; margin-bottom: 16px; margin-right: 6px; margin-top: 2px; outline: 0 none; padding: 3px; width: 100%; } input[type="text"]:focus{ border-color:#5b9dd9; -webkit-box-shadow:0 0 2px rgba(30,140,190,.8); box-shadow:0 0 2px rgba(30,140,190,.8) } input[type="submit"]{ float:right; } label{ color:#777; font-size:14px; cursor:pointer; vertical-align:middle; text-align: left; } table { width:355px; margin-left:auto; margin-right:auto; } #mapping-options { width:555px; } #mapping-authenticate { display:none; } #mapping-complete-info { display:none; } .error { display:none; background-color: #fff; border-left: 4px solid #dd3d36; box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1); margin: 0 21px; padding: 12px; text-align:left; } .back-to-options { float: left; margin: 7px 0px; } .back-to-home { font-size: 12px; margin-top: -18px; } .back-to-home a { color: #999; text-decoration: none; } <?php if ($linking_enabled == 2) { ?> #login {width: 400px;} #welcome, #mapping-options, #errors-account-linking, #mapping-complete-info {display: none;} #errors-profile-completion, #mapping-complete-info {display: block;} <?php } elseif ($bouncer_account_linking) { ?> #login {width: 400px;} #welcome, #mapping-options, #errors-profile-completion, #mapping-complete-info {display: none;} #errors-account-linking, #mapping-authenticate {display: block;} <?php } elseif ($bouncer_profile_completion) { ?> #login {width: 400px;} #welcome, #mapping-options, #errors-account-linking, #mapping-complete-info {display: none;} #errors-profile-completion, #mapping-complete-info {display: block;} <?php } ?> </style> <script> // good old time function toggleEl( el, display ) { if( el = document.getElementById( el ) ) { el.style.display = display; } } function toggleWidth( el, width ) { if( el = document.getElementById( el ) ) { el.style.width = width; } } function display_mapping_options() { toggleWidth( 'login', '616px' ); toggleEl( 'welcome' , 'block' ); toggleEl( 'mapping-options', 'block' ); toggleEl( 'errors-profile-completion', 'none' ); toggleEl( 'mapping-authenticate' , 'none' ); toggleEl( 'errors-account-linking', 'none' ); toggleEl( 'mapping-complete-info' , 'none' ); } function display_mapping_authenticate() { toggleWidth( 'login', '400px' ); toggleEl( 'welcome' , 'none' ); toggleEl( 'mapping-options', 'none' ); toggleEl( 'errors-account-linking', 'block' ); toggleEl( 'mapping-authenticate' , 'block' ); toggleEl( 'errors-profile-completion', 'none' ); toggleEl( 'mapping-complete-info' ,'none' ); } function display_mapping_complete_info() { toggleWidth( 'login', '400px' ); toggleEl( 'welcome' , 'none' ); toggleEl( 'mapping-options', 'none' ); toggleEl( 'errors-account-linking', 'none' ); toggleEl( 'mapping-authenticate' , 'none' ); toggleEl( 'errors-profile-completion', 'block' ); toggleEl( 'mapping-complete-info' , 'block' ); } </script> </head> <body> <div id="login"> <div id="login-panel"> <div id="avatar"> <img src="<?php echo $hybridauth_user_avatar; ?> "> </div> <div id="welcome"> <img id="idp-icon" src="<?php echo $assets_base_url . $provider; ?> .png" > <b><?php printf(_wsl__("Hi %s", 'wordpress-social-login'), htmlentities($hybridauth_user_profile->displayName)); ?> </b> <p><?php printf(_wsl__("You're now signed in with your %s account but you still one step away of getting into our website", 'wordpress-social-login'), $provider); ?> .</p> <hr /> </div> <table id="mapping-options" border="0"> <tr> <?php if ($linking_enabled == 1) { ?> <td valign="top" width="50%" style="text-align:center;"> <h4><?php _wsl_e("Already have an account", 'wordpress-social-login'); ?> ?</h4> <p style="font-size: 12px;"><?php printf(_wsl__("Link your existing account on our website to your %s ID.", 'wordpress-social-login'), $provider); ?> </p> </td> <?php } ?> <td valign="top" width="50%" style="text-align:center;"> <h4><?php _wsl_e("New to our website", 'wordpress-social-login'); ?> ?</h4> <p style="font-size: 12px;"><?php printf(_wsl__("Create a new account and it will be associated with your %s ID.", 'wordpress-social-login'), $provider); ?> </p> </td> </tr> <tr> <?php if ($linking_enabled == 1) { ?> <td valign="top" width="50%" style="text-align:center;"> <input type="button" value="<?php _wsl_e("Link my account", 'wordpress-social-login'); ?> " class="button-primary" onclick="display_mapping_authenticate();" > </td> <?php } ?> <td valign="top" width="50%" style="text-align:center;"> <input type="button" value="<?php _wsl_e("Create a new account", 'wordpress-social-login'); ?> " class="button-primary" onclick="display_mapping_complete_info();" > </td> </tr> </table> <?php if ($account_linking_errors) { echo '<div id="errors-account-linking" class="error">'; foreach ($account_linking_errors as $error) { ?> <p><?php echo $error; ?> </p><?php } echo '</div>'; } if ($profile_completion_errors) { echo '<div id="errors-profile-completion" class="error">'; foreach ($profile_completion_errors as $error) { ?> <p><?php echo $error; ?> </p><?php } echo '</div>'; } ?> <form method="post" action="<?php echo site_url('wp-login.php', 'login_post'); ?> " id="login-form"> <table id="mapping-authenticate" border="0"> <tr> <td valign="top" width="50%" style="text-align:center;"> <h4><?php _wsl_e("Already have an account", 'wordpress-social-login'); ?> ?</h4> <p><?php printf(_wsl__("Please enter your username and password of your existing account on our website. Once verified, it will linked to your % ID", 'wordpress-social-login'), ucfirst($provider)); ?> .</p> </td> </tr> <tr> <td valign="bottom" width="50%" style="text-align:left;"> <label> <?php _wsl_e("Username", 'wordpress-social-login'); ?> <br /> <input type="text" name="user_login" class="input" value="" size="25" placeholder="" /> </label> <label> <?php _wsl_e("Password", 'wordpress-social-login'); ?> <br /> <input type="text" name="user_password" class="input" value="" size="25" placeholder="" /> </label> <input type="submit" value="<?php _wsl_e("Continue", 'wordpress-social-login'); ?> " class="button-primary" > <a href="javascript:void(0);" onclick="display_mapping_options();" class="back-to-options"><?php _wsl_e("Back", 'wordpress-social-login'); ?> </a> </td> </tr> </table> <input type="hidden" id="redirect_to" name="redirect_to" value="<?php echo $redirect_to; ?> "> <input type="hidden" id="provider" name="provider" value="<?php echo $provider; ?> "> <input type="hidden" id="action" name="action" value="wordpress_social_account_linking"> <input type="hidden" id="bouncer_account_linking" name="bouncer_account_linking" value="1"> </form> <form method="post" action="<?php echo site_url('wp-login.php', 'login_post'); ?> " id="login-form"> <table id="mapping-complete-info" border="0"> <tr> <td valign="top" width="50%" style="text-align:center;"> <?php if ($linking_enabled == 1) { ?> <h4><?php _wsl_e("New to our website", 'wordpress-social-login'); ?> ?</h4> <?php } ?> <p><?php printf(_wsl__("Please fill in your information in the form below. Once completed, you will be able to automatically sign into our website through your %s ID", 'wordpress-social-login'), ucfirst($provider)); ?> .</p> </td> </tr> <tr> <td valign="bottom" width="50%" style="text-align:left;"> <label> <?php _wsl_e("Username", 'wordpress-social-login'); ?> <br /> <input type="text" name="user_name" class="input" value="<?php echo $requested_user_login; ?> " size="25" placeholder="" /> </label> <label> <?php _wsl_e("E-mail", 'wordpress-social-login'); ?> <br /> <input type="text" name="user_email" class="input" value="<?php echo $requested_user_email; ?> " size="25" placeholder="" /> </label> <?php /** * Fires following the 'E-mail' field in the user registration form. * * hopefully, this won't become a pain in future * * Ref: http://codex.wordpress.org/Plugin_API/Action_Reference/register_form */ $extra_fields = get_option('wsl_settings_bouncer_profile_completion_hook_extra_fields'); if ($extra_fields == 1) { do_action('register_form'); } ?> <input type="submit" value="<?php _wsl_e("Continue", 'wordpress-social-login'); ?> " class="button-primary" > <?php if ($linking_enabled == 1) { ?> <a href="javascript:void(0);" onclick="display_mapping_options();" class="back-to-options"><?php _wsl_e("Back", 'wordpress-social-login'); ?> </a> <?php } ?> </td> </tr> </table> <input type="hidden" id="redirect_to" name="redirect_to" value="<?php echo $redirect_to; ?> "> <input type="hidden" id="provider" name="provider" value="<?php echo $provider; ?> "> <input type="hidden" id="action" name="action" value="wordpress_social_account_linking"> <input type="hidden" id="bouncer_profile_completion" name="bouncer_profile_completion" value="1"> </form> </div> <p class="back-to-home"> <a href="<?php echo site_url(); ?> ">← <?php printf(_wsl__("Back to %s", 'wordpress-social-login'), get_bloginfo('name')); ?> </a> </p> </div> <?php // Development mode on? if (get_option('wsl_settings_development_mode_enabled')) { wsl_display_dev_mode_debugging_area(); } ?> </body> </html> <?php die; } return array($shall_pass, $user_id, $requested_user_login, $requested_user_email); }
function wsl_render_redirect_to_provider_loading_screen($provider) { $assets_base_url = WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL . '/assets/img/'; ?> <!DOCTYPE html> <head> <meta name="robots" content="NOINDEX, NOFOLLOW"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title><?php _wsl_e("Redirecting...", 'wordpress-social-login'); ?> - <?php bloginfo('name'); ?> </title> <style type="text/css"> html { background: #f1f1f1; } body { background: #fff; color: #444; font-family: "Open Sans", sans-serif; margin: 2em auto; padding: 1em 2em; max-width: 700px; -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.13); box-shadow: 0 1px 3px rgba(0,0,0,0.13); } #loading-screen { margin-top: 50px; } #loading-screen div{ line-height: 20px; padding: 8px; background-color: #f2f2f2; border: 1px solid #ccc; padding: 10px; text-align:center; box-shadow: 0 1px 3px rgba(0,0,0,0.13); margin-top:25px; } </style> <script> function init() { window.location.replace( window.location.href + "&redirect_to_provider=true" ); } </script> </head> <body id="loading-screen" onload="init();"> <table width="100%" border="0"> <tr> <td align="center"><img src="<?php echo $assets_base_url; ?> loading.gif" /></td> </tr> <tr> <td align="center"> <div> <?php echo sprintf(_wsl__("Contacting <b>%s</b>, please wait...", 'wordpress-social-login'), _wsl__(ucfirst($provider), 'wordpress-social-login')); ?> </div> </td> </tr> </table> </body> </html> <?php die; }