Completed
Push — master ( b5e561...2d3b37 )
by
unknown
19:22 queued 05:30
created

wps-switching.php ➔ wps_display_user_switching_link()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 3
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * WpShop Uer switching
4
 *
5
 * @author Eoxia dev team <[email protected]>
6
 * @version
7
 * @package includes
8
 * @subpackage modules
9
 */
10
11
if ( ! defined( 'ABSPATH' ) ) {
12
	exit;
13
}
14
15
if ( ! defined( 'WPSHOP_VERSION' ) ) {
16
	die( __( 'You are not allowed to use this service.', 'wpshop' ) );
17
}
18
19
/** Test if userswithcing module is active */
20
if ( class_exists( 'user_switching' ) ) {
21
	add_filter( 'wps_filter_customer_action_metabox', 'wps_display_user_switching_link', 10, 2 );
22
	add_filter( 'wps_filter_customer_list_actions', 'wps_display_user_switching_link', 10, 2 );
23
	add_filter( 'wps_filter_customer_in_order', 'wps_display_user_switching_link', 10, 2 );
24
25
	/**
26
	 * Display the link allowing to switch to another user everywhere it is possible
27
	 *
28
	 * @param  integer $customer_id The WPShop customer id (equals to post id).
29
	 * @param  integer $wp_user_id  Corresponding user id.
30
	 */
31
	function wps_display_user_switching_link( $customer_id, $wp_user_id, $need_separator = true ) {
0 ignored issues
show
Unused Code introduced by
The parameter $customer_id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $need_separator is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
32
		$user = get_user_by( 'id', $wp_user_id );
33
		$output = '<a href="' . esc_url( user_switching::switch_to_url( $user ) ) . '" >' . esc_html( 'Switch to user', 'wpshop' ) . '</a>';
34
35
		echo $output;
36
	}
37
}
38