Changeset 1711810
- Timestamp:
- 08/10/2017 10:27:16 PM (9 years ago)
- Location:
- userecho
- Files:
-
- 2 edited
- 1 copied
-
tags/1.0.6 (copied) (copied from userecho/trunk)
-
tags/1.0.6/userecho.php (modified) (13 diffs)
-
trunk/userecho.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
userecho/tags/1.0.6/userecho.php
r1542874 r1711810 2 2 /* 3 3 Plugin Name: UserEcho for Wordpress - collect feedback for your blog 4 Version: 1.0. 55 Plugin URI: http ://userecho.com4 Version: 1.0.6 5 Plugin URI: https://userecho.com 6 6 Author: Jonathan Champ, Sergey Stukov, Vladimir Mullagaliyev 7 Author URI: http ://userecho.com7 Author URI: https://userecho.com 8 8 Description: UserEcho - feedback widget to collect and manage user feedback for your blog. 9 9 License: GPLv2 … … 29 29 class UserEcho { 30 30 public function __construct() { 31 $this->check_if_sso_login(); 31 32 load_plugin_textdomain( 'UserEcho', false, basename( dirname( __FILE__ ) ) . '/lang' ); 32 33 33 34 add_action( 'admin_menu', array( $this, 'add_menu' ), 20 ); 34 add_action( 'template_redirect', array( $this, 'login' ), 1 );35 35 add_action( 'wp_footer', array( $this, 'show_tab_widget' ) ); 36 36 … … 65 65 $options['tab_icon_show'] = !empty( $_POST['tab_icon_show'] ); 66 66 $options['verified_email'] = !empty( $_POST['verified_email'] ); 67 67 68 if ( !empty( $_POST['forum'] ) ) { $options['forum'] = $_POST['forum']; } 68 69 if ( !empty( $_POST['tab_corner_radius'] ) ) { $options['tab_corner_radius'] = $_POST['tab_corner_radius']; } … … 123 124 124 125 if ( !empty( $options['language'] ) ) { 125 $language_options += array( $options['language'] => 'Custom (' + $options['language'] +')' );126 $language_options += array( $options['language'] => 'Custom ('.$options['language'].')' ); 126 127 } 127 128 … … 130 131 <div id="icon-options-general" class="icon32"><br></div> 131 132 <h2>UserEcho integration Settings</h2> 132 <h3>Tab widget:</h3>133 134 133 <form method="post" action=""> 135 134 <?php wp_nonce_field( 'userecho' ); ?> 136 135 <input type="hidden" name="ue_action" value="edit" /> 137 136 <div class="table"> 137 <h3>Common:</h3> 138 138 <table class="form-table"> 139 139 <tbody> 140 140 <tr valign="top"> 141 <th><?php _e( 'Show UserEcho tab widget', 'UserEcho' ); ?></th> 141 <th><?php _e( 'Domain', 'UserEcho' ); ?></th> 142 <td> 143 <input id="domain" name="domain" type="text" class="regular-text" value="<?php echo esc_attr( $options['domain'] ); ?>" /> 144 <span class="description"><?php _e( 'Your UserEcho community url (UE subdomain or custom domain, depends on project settings).', 'UserEcho' ); ?></span> 145 </td> 146 </tr> 147 </tbody> 148 </table> 149 <h3>Tab widget:</h3> 150 <table class="form-table"> 151 <tbody> 152 <tr valign="top"> 153 <th><?php _e( 'Show tab', 'UserEcho' ); ?></th> 142 154 <td> 143 155 <input id="show_tab" name="show_tab" type="checkbox" value="1"<?php checked( $options['show_tab'], '1' ); ?> /> … … 145 157 </tr> 146 158 <tr valign="top"> 147 <th><?php _e( 'Domain', 'UserEcho' ); ?></th>148 <td>149 <input id="domain" name="domain" type="text" class="regular-text" value="<?php echo esc_attr( $options['domain'] ); ?>" />150 <span class="description"><?php _e( 'Your UserEcho community url.', 'UserEcho' ); ?></span>151 </td>152 </tr>153 <tr valign="top">154 159 <th><?php _e( 'Forum id', 'UserEcho' ); ?></th> 155 160 <td> 156 161 <input id="forum" name="forum" type="text" class="regular-text" value="<?php echo esc_attr( $options['forum'] ); ?>" /> 157 <span class="description"><?php _e( ' Move mouse over forum name at the your UserEcho community right panel. And find out forum id in the browser status bar.', 'UserEcho' ); ?></span>162 <span class="description"><?php _e( 'Add a forum ID you would like to see in the widget.', 'UserEcho' ); ?></span> 158 163 </td> 159 164 </tr> … … 169 174 </tr> 170 175 171 </tbody> 172 173 </table> 174 <h3>Tab visual style:</h3> 175 <table class="form-table"><tbody> 176 177 178 <tr valign="top"> 176 </tbody> 177 </table> 178 <h3>Tab visual style:</h3> 179 <table class="form-table"><tbody> 180 <tr valign="top"> 179 181 <th><?php _e( 'Font size', 'UserEcho' ); ?></th> 180 182 <td> … … 230 232 </tbody> 231 233 </table> 232 <h3>Single Sign On (SSO):</h3>234 <h3>Single Sign On (SSO):</h3> 233 235 <table class="form-table"> 234 236 <tbody> 235 237 <tr valign="top"> 236 <th><?php _e( ' APIKey', 'UserEcho' ); ?></th>238 <th><?php _e( 'SSO Key', 'UserEcho' ); ?></th> 237 239 <td> 238 240 <input id="api_key" name="api_key" type="text" class="regular-text" value="<?php echo esc_attr( $options['api_key'] ); ?>" /> 241 <span class="description"><?php _e( 'Available in your SSO settings.', 'UserEcho' ); ?></span> 239 242 </td> 240 243 </tr> … … 243 246 <td> 244 247 <input id="verified_email" name="verified_email" type="checkbox" value="1"<?php checked( $options['verified_email'], '1' ); ?> /> 248 <span class="description"><?php _e( 'If checked user email will be marked as verified.', 'UserEcho' ); ?></span> 245 249 </td> 246 250 </tr> … … 263 267 $default = array( 264 268 'api_key' => '', 265 'domain' => ' YOUR_ALIAS.userecho.com',269 'domain' => '[YOUR_ALIAS].userecho.com', 266 270 'show_tab' => 1, 267 271 'language' => 'en', … … 276 280 'tab_icon_show' => 1, 277 281 'verified_email' => 1, 278 279 282 ); 280 283 } … … 382 385 383 386 384 385 public function login() { 386 // Perform login on ?userecho_sso_login=1 387 if ( empty( $_GET['userecho_sso_login'] ) ) { 388 return; 389 } 390 391 $options = $this->get_options(); 392 393 $base_url = 'http://' . $options['domain'] . '/'; 394 395 if ( empty( $options['api_key'] ) ) { 396 //if api_key not provided just go to the userecho forum without authorization, like simple link was clciked 397 header( 'Location: ' . $base_url ); 398 die(); 399 return; 400 } 401 387 public function check_if_sso_login() 388 { 389 global $current_user, $pagenow; 390 #http://127.0.0.1/wordpress/wp-login.php 391 # http://127.0.0.1/wordpress/wp-login.php?host_url=https://userecho.com&action=ue-login 402 392 403 if ( isset( $_GET['return'] ) && strpos( $_GET['return'], $base_url ) === 0 ) { 404 $base_url = $_GET['return']; 405 } 406 407 $redirect = $base_url; 408 409 $sso_token = $this->get_sso_token(); 410 if ($sso_token){ 411 $redirect .= '?sso_token=' . $this->get_sso_token(); 412 } 413 414 header( 'Location: ' . $redirect ); 415 die(); 393 if ( 'wp-login.php' == $pagenow ){ 394 $options = $this->get_options(); 395 if ( ! isset( $_REQUEST['return'] ) || ! isset( $_GET['action'] )) { 396 return; 397 } 398 $return_url = $_REQUEST['return']; 399 if( ! $return_url ) { 400 return; 401 } 402 if ( $_GET['action'] == 'ue-login' ) { 403 if ( !empty( $current_user->ID) ) { 404 // If user is logged into WP, generate SSO and redirect him back to UE 405 header( 'Location: '.$this->get_sso_redirect_url($return_url) ) ; 406 die(); 407 } 408 else{ 409 if (isset($return_url)){ 410 header( "Location: " .wp_login_url()."?redirect_to=ue_sso_redirect_to=".$return_url ); 411 die(); 412 } 413 } 414 } 415 } 416 } 417 public function get_sso_redirect_url($return_url){ 418 return $return_url . '?sso_token=' . $this->get_sso_token(); 416 419 } 417 420 } … … 531 534 532 535 $ue = new UserEcho(); 536 537 # Redirect back to UE after login if it's login via SSO 538 add_filter( 'login_redirect', 'ue_sso_login_redirect', 10, 3 ); 539 function ue_sso_login_redirect($url, $request, $user) { 540 global $ue; 541 parse_str( $request, $params ); 542 if ( ! isset($params['ue_sso_redirect_to']) ) { 543 return $url; 544 } 545 $return_url = $params['ue_sso_redirect_to']; 546 if ( ! $return_url ) { 547 return $url; 548 } 549 550 if (isset( $_REQUEST['wp-submit'] ) && $_REQUEST['wp-submit'] == "Log In" && is_a( $user, 'WP_User' )) { 551 header("Location: ".$ue->get_sso_redirect_url($return_url)); 552 die(); 553 } 554 return $request; 555 } -
userecho/trunk/userecho.php
r1542874 r1711810 2 2 /* 3 3 Plugin Name: UserEcho for Wordpress - collect feedback for your blog 4 Version: 1.0. 55 Plugin URI: http ://userecho.com4 Version: 1.0.6 5 Plugin URI: https://userecho.com 6 6 Author: Jonathan Champ, Sergey Stukov, Vladimir Mullagaliyev 7 Author URI: http ://userecho.com7 Author URI: https://userecho.com 8 8 Description: UserEcho - feedback widget to collect and manage user feedback for your blog. 9 9 License: GPLv2 … … 29 29 class UserEcho { 30 30 public function __construct() { 31 $this->check_if_sso_login(); 31 32 load_plugin_textdomain( 'UserEcho', false, basename( dirname( __FILE__ ) ) . '/lang' ); 32 33 33 34 add_action( 'admin_menu', array( $this, 'add_menu' ), 20 ); 34 add_action( 'template_redirect', array( $this, 'login' ), 1 );35 35 add_action( 'wp_footer', array( $this, 'show_tab_widget' ) ); 36 36 … … 65 65 $options['tab_icon_show'] = !empty( $_POST['tab_icon_show'] ); 66 66 $options['verified_email'] = !empty( $_POST['verified_email'] ); 67 67 68 if ( !empty( $_POST['forum'] ) ) { $options['forum'] = $_POST['forum']; } 68 69 if ( !empty( $_POST['tab_corner_radius'] ) ) { $options['tab_corner_radius'] = $_POST['tab_corner_radius']; } … … 123 124 124 125 if ( !empty( $options['language'] ) ) { 125 $language_options += array( $options['language'] => 'Custom (' + $options['language'] +')' );126 $language_options += array( $options['language'] => 'Custom ('.$options['language'].')' ); 126 127 } 127 128 … … 130 131 <div id="icon-options-general" class="icon32"><br></div> 131 132 <h2>UserEcho integration Settings</h2> 132 <h3>Tab widget:</h3>133 134 133 <form method="post" action=""> 135 134 <?php wp_nonce_field( 'userecho' ); ?> 136 135 <input type="hidden" name="ue_action" value="edit" /> 137 136 <div class="table"> 137 <h3>Common:</h3> 138 138 <table class="form-table"> 139 139 <tbody> 140 140 <tr valign="top"> 141 <th><?php _e( 'Show UserEcho tab widget', 'UserEcho' ); ?></th> 141 <th><?php _e( 'Domain', 'UserEcho' ); ?></th> 142 <td> 143 <input id="domain" name="domain" type="text" class="regular-text" value="<?php echo esc_attr( $options['domain'] ); ?>" /> 144 <span class="description"><?php _e( 'Your UserEcho community url (UE subdomain or custom domain, depends on project settings).', 'UserEcho' ); ?></span> 145 </td> 146 </tr> 147 </tbody> 148 </table> 149 <h3>Tab widget:</h3> 150 <table class="form-table"> 151 <tbody> 152 <tr valign="top"> 153 <th><?php _e( 'Show tab', 'UserEcho' ); ?></th> 142 154 <td> 143 155 <input id="show_tab" name="show_tab" type="checkbox" value="1"<?php checked( $options['show_tab'], '1' ); ?> /> … … 145 157 </tr> 146 158 <tr valign="top"> 147 <th><?php _e( 'Domain', 'UserEcho' ); ?></th>148 <td>149 <input id="domain" name="domain" type="text" class="regular-text" value="<?php echo esc_attr( $options['domain'] ); ?>" />150 <span class="description"><?php _e( 'Your UserEcho community url.', 'UserEcho' ); ?></span>151 </td>152 </tr>153 <tr valign="top">154 159 <th><?php _e( 'Forum id', 'UserEcho' ); ?></th> 155 160 <td> 156 161 <input id="forum" name="forum" type="text" class="regular-text" value="<?php echo esc_attr( $options['forum'] ); ?>" /> 157 <span class="description"><?php _e( ' Move mouse over forum name at the your UserEcho community right panel. And find out forum id in the browser status bar.', 'UserEcho' ); ?></span>162 <span class="description"><?php _e( 'Add a forum ID you would like to see in the widget.', 'UserEcho' ); ?></span> 158 163 </td> 159 164 </tr> … … 169 174 </tr> 170 175 171 </tbody> 172 173 </table> 174 <h3>Tab visual style:</h3> 175 <table class="form-table"><tbody> 176 177 178 <tr valign="top"> 176 </tbody> 177 </table> 178 <h3>Tab visual style:</h3> 179 <table class="form-table"><tbody> 180 <tr valign="top"> 179 181 <th><?php _e( 'Font size', 'UserEcho' ); ?></th> 180 182 <td> … … 230 232 </tbody> 231 233 </table> 232 <h3>Single Sign On (SSO):</h3>234 <h3>Single Sign On (SSO):</h3> 233 235 <table class="form-table"> 234 236 <tbody> 235 237 <tr valign="top"> 236 <th><?php _e( ' APIKey', 'UserEcho' ); ?></th>238 <th><?php _e( 'SSO Key', 'UserEcho' ); ?></th> 237 239 <td> 238 240 <input id="api_key" name="api_key" type="text" class="regular-text" value="<?php echo esc_attr( $options['api_key'] ); ?>" /> 241 <span class="description"><?php _e( 'Available in your SSO settings.', 'UserEcho' ); ?></span> 239 242 </td> 240 243 </tr> … … 243 246 <td> 244 247 <input id="verified_email" name="verified_email" type="checkbox" value="1"<?php checked( $options['verified_email'], '1' ); ?> /> 248 <span class="description"><?php _e( 'If checked user email will be marked as verified.', 'UserEcho' ); ?></span> 245 249 </td> 246 250 </tr> … … 263 267 $default = array( 264 268 'api_key' => '', 265 'domain' => ' YOUR_ALIAS.userecho.com',269 'domain' => '[YOUR_ALIAS].userecho.com', 266 270 'show_tab' => 1, 267 271 'language' => 'en', … … 276 280 'tab_icon_show' => 1, 277 281 'verified_email' => 1, 278 279 282 ); 280 283 } … … 382 385 383 386 384 385 public function login() { 386 // Perform login on ?userecho_sso_login=1 387 if ( empty( $_GET['userecho_sso_login'] ) ) { 388 return; 389 } 390 391 $options = $this->get_options(); 392 393 $base_url = 'http://' . $options['domain'] . '/'; 394 395 if ( empty( $options['api_key'] ) ) { 396 //if api_key not provided just go to the userecho forum without authorization, like simple link was clciked 397 header( 'Location: ' . $base_url ); 398 die(); 399 return; 400 } 401 387 public function check_if_sso_login() 388 { 389 global $current_user, $pagenow; 390 #http://127.0.0.1/wordpress/wp-login.php 391 # http://127.0.0.1/wordpress/wp-login.php?host_url=https://userecho.com&action=ue-login 402 392 403 if ( isset( $_GET['return'] ) && strpos( $_GET['return'], $base_url ) === 0 ) { 404 $base_url = $_GET['return']; 405 } 406 407 $redirect = $base_url; 408 409 $sso_token = $this->get_sso_token(); 410 if ($sso_token){ 411 $redirect .= '?sso_token=' . $this->get_sso_token(); 412 } 413 414 header( 'Location: ' . $redirect ); 415 die(); 393 if ( 'wp-login.php' == $pagenow ){ 394 $options = $this->get_options(); 395 if ( ! isset( $_REQUEST['return'] ) || ! isset( $_GET['action'] )) { 396 return; 397 } 398 $return_url = $_REQUEST['return']; 399 if( ! $return_url ) { 400 return; 401 } 402 if ( $_GET['action'] == 'ue-login' ) { 403 if ( !empty( $current_user->ID) ) { 404 // If user is logged into WP, generate SSO and redirect him back to UE 405 header( 'Location: '.$this->get_sso_redirect_url($return_url) ) ; 406 die(); 407 } 408 else{ 409 if (isset($return_url)){ 410 header( "Location: " .wp_login_url()."?redirect_to=ue_sso_redirect_to=".$return_url ); 411 die(); 412 } 413 } 414 } 415 } 416 } 417 public function get_sso_redirect_url($return_url){ 418 return $return_url . '?sso_token=' . $this->get_sso_token(); 416 419 } 417 420 } … … 531 534 532 535 $ue = new UserEcho(); 536 537 # Redirect back to UE after login if it's login via SSO 538 add_filter( 'login_redirect', 'ue_sso_login_redirect', 10, 3 ); 539 function ue_sso_login_redirect($url, $request, $user) { 540 global $ue; 541 parse_str( $request, $params ); 542 if ( ! isset($params['ue_sso_redirect_to']) ) { 543 return $url; 544 } 545 $return_url = $params['ue_sso_redirect_to']; 546 if ( ! $return_url ) { 547 return $url; 548 } 549 550 if (isset( $_REQUEST['wp-submit'] ) && $_REQUEST['wp-submit'] == "Log In" && is_a( $user, 'WP_User' )) { 551 header("Location: ".$ue->get_sso_redirect_url($return_url)); 552 die(); 553 } 554 return $request; 555 }
Note: See TracChangeset
for help on using the changeset viewer.