/** * @param $args * @param $instance * * @return string */ public function getContent($args, $instance) { $output = ''; $title = apply_filters('widget_title', $instance['title']); // Get the data from the argument. require_once GIGYA__PLUGIN_DIR . 'features/login/GigyaLoginSet.php'; $login = new GigyaLoginSet(); $data = $login->getParams(); // Override params or take the defaults. if (!empty($instance['override'])) { foreach ($instance as $key => $value) { if (!empty($value)) { $data['ui'][$key] = esc_attr($value); } } } // Set the output. $output .= $args['before_widget']; if (!empty($title)) { $output .= $args['before_title'] . $title . $args['after_title']; } if (!is_user_logged_in()) { $output .= '<div class="gigya-login-widget"></div>'; $output .= '<script class="data-login" type="application/json">' . json_encode($data) . '</script>'; } else { $current_user = wp_get_current_user(); $output .= '<div class="gigya-wp-account-widget">'; $output .= '<a class="gigya-wp-avatar" href="' . user_admin_url('profile.php') . '">' . get_avatar($current_user->ID) . '</a>'; $output .= '<div class="gigya-wp-info">'; $output .= '<a class="gigya-wp-name" href="' . user_admin_url('profile.php') . '">' . $current_user->display_name . '</a>'; $output .= '<a class="gigya-wp-logout" href="' . wp_logout_url() . '">' . __('Log Out') . '</a>'; $output .= '</div></div>'; } $output .= $args['after_widget']; return $output; }
public function gigyaSocialLoginScode($attrs) { require_once GIGYA__PLUGIN_DIR . 'features/login/GigyaLoginSet.php'; $login = new GigyaLoginSet(); $defaults = $login->getParams(); if (empty($attrs)) { $attrs = $defaults; if (isset($attrs['advanced'])) { $advanced = gigyaCms::jsonToArray($attrs['advanced']); if (is_array($advanced)) { $attrs = array_merge($attrs, $advanced); } else { if (is_string($advanced)) { _gigya_error_log("Error in " . __FUNCTION__ . " shortcode advanced parameters message: " . $advanced); } } } } else { $attrs = $this->attrs_to_gigya($attrs); // If custom attributes are passed with shortcode, use them to replace the ui array of the default ui values $ui_arr = $defaults['ui']; $ui_arr_updated = array_replace($ui_arr, $attrs); $defaults['ui'] = $ui_arr_updated; $attrs = $defaults; } if (!is_user_logged_in()) { $output = '<div class="gigya-login-widget"></div>'; $output .= '<script class="data-login" type="application/json">' . json_encode($attrs) . '</script>'; } else { $current_user = wp_get_current_user(); $output = '<div class="gigya-wp-account-widget">'; $output .= '<a class="gigya-wp-avatar" href="' . user_admin_url('profile.php') . '">' . get_avatar($current_user->ID) . '</a>'; $output .= '<div class="gigya-wp-info">'; $output .= '<a class="gigya-wp-name" href="' . user_admin_url('profile.php') . '">' . $current_user->display_name . '</a>'; $output .= '<a class="gigya-wp-logout" href="' . wp_logout_url() . '">' . __('Log Out') . '</a>'; $output .= '</div></div>'; } return $output; }