Password.php
1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
namespace AC\Settings\Column;
use AC\Settings;
use AC\View;
class Password extends Settings\Column
implements Settings\FormatValue {
/**
* @var string
*/
private $password;
protected function define_options() {
return [ 'password' ];
}
public function create_view() {
$select = $this->create_element( 'select' )
->set_options( [
'' => __( 'Password', 'codepress-admin-column' ), // default
'text' => __( 'Plain text', 'codepress-admin-column' ),
] );
$view = new View( [
'label' => __( 'Display format', 'codepress-admin-columns' ),
'setting' => $select,
] );
return $view;
}
/**
* @return string
*/
public function get_password() {
return $this->password;
}
/**
* @param string $password
*
* @return true
*/
public function set_password( $password ) {
$this->password = $password;
return true;
}
public function format( $value, $original_value ) {
if ( ! $this->get_password() ) {
$pwchar = '•';
$value = $value ? str_pad( '', strlen( $value ) * strlen( $pwchar ), $pwchar ) : '';
}
return $value;
}
}