PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 4.3.2
Admin Columns v4.3.2
7.0.19 2.3.5 2.4 2.4.1 2.4.10 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.6.1 2.5.6.2 2.5.6.3 2.5.6.4 3.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.7 3.1 3.1.1 3.1.10 3.1.2 3.1.3 3.1.5 3.2.3 3.2.7 3.3.1 3.4.1 3.4.6 3.4.8 4.0.1 4.0.3 4.1.6 4.2.2 4.2.5 4.3 4.3.2 4.4.1 4.4.4 4.4.5 4.5.5 4.6.1 4.7.18 4.7.19 4.7.20 4.7.7 7.0.13 7.0.14 7.0.16 trunk 1.0 1.1 1.1.3 1.2 1.2.1 1.3 1.3.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.5.1 1.4.6 1.4.6.1 1.4.6.2 1.4.6.3 1.4.6.4 1.4.7 1.4.8 1.4.9 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2 2.2.1 2.2.1.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.5.1 2.2.6 2.2.6.1 2.2.6.2 2.2.6.3 2.2.6.4 2.2.7 2.2.8 2.2.8.1 2.2.9 2.3.1 2.3.2 2.3.3
codepress-admin-columns / classes / Settings / Column / Width.php
codepress-admin-columns / classes / Settings / Column Last commit date
BeforeAfter 5 years ago Pro 5 years ago ActionIcons.php 5 years ago AttachmentDisplay.php 5 years ago BeforeAfter.php 5 years ago CharacterLimit.php 5 years ago Comment.php 5 years ago CommentCount.php 5 years ago CommentLink.php 5 years ago CustomField.php 5 years ago CustomFieldType.php 5 years ago Date.php 5 years ago DateTimeFormat.php 5 years ago ExifData.php 5 years ago Image.php 5 years ago Images.php 5 years ago Label.php 5 years ago LinkLabel.php 5 years ago LinkToMenu.php 5 years ago MediaLink.php 5 years ago Message.php 5 years ago Meta.php 5 years ago MissingImageSize.php 5 years ago NumberFormat.php 5 years ago NumberOfItems.php 5 years ago Password.php 5 years ago PathScope.php 5 years ago Post.php 5 years ago PostFormatIcon.php 5 years ago PostLink.php 5 years ago PostStatus.php 5 years ago PostType.php 5 years ago Pro.php 5 years ago Separator.php 5 years ago StatusIcon.php 5 years ago StringLimit.php 5 years ago Taxonomy.php 5 years ago Term.php 5 years ago TermLink.php 5 years ago Time.php 5 years ago Toggle.php 5 years ago Type.php 5 years ago User.php 5 years ago UserLink.php 5 years ago Width.php 5 years ago WordLimit.php 5 years ago WordsPerMinute.php 5 years ago
Width.php
136 lines
1 <?php
2
3 namespace AC\Settings\Column;
4
5 use AC\Settings;
6 use AC\View;
7
8 class Width extends Settings\Column
9 implements Settings\Header {
10
11 /**
12 * @var integer
13 */
14 private $width;
15
16 /**
17 * @var string
18 */
19 private $width_unit;
20
21 protected function define_options() {
22 return [
23 'width',
24 'width_unit' => '%',
25 ];
26 }
27
28 private function get_valid_width_units() {
29 return [
30 '%' => '%',
31 'px' => 'px',
32 ];
33 }
34
35 private function is_valid_width_unit( $width_unit ) {
36 return array_key_exists( $width_unit, $this->get_valid_width_units() );
37 }
38
39 public function create_view() {
40 $width = $this->create_element( 'text' )
41 ->set_attribute( 'placeholder', __( 'Auto', 'codepress-admin-columns' ) )
42 ->set_attribute( 'data-width-input', '' );
43
44 $unit = $this->create_element( 'radio', 'width_unit' )
45 ->set_attribute( 'data-unit-input', '' )
46 ->set_options( $this->get_valid_width_units() );
47
48 $section = new View( [
49 'width' => $width,
50 'unit' => $unit,
51 ] );
52 $section->set_template( 'settings/setting-width' );
53
54 $view = new View( [
55 'label' => __( 'Width', 'codepress-admin-columns' ),
56 'sections' => [ $section ],
57 ] );
58
59 return $view;
60 }
61
62 public function create_header_view() {
63
64 $view = new View( [
65 'title' => __( 'width', 'codepress-admin-columns' ),
66 'content' => $this->get_display_width(),
67 ] );
68
69 return $view;
70 }
71
72 /**
73 * @return int
74 */
75 public function get_width() {
76 return $this->width;
77 }
78
79 /**
80 * @param $value
81 *
82 * @return bool
83 */
84 public function set_width( $value ) {
85
86 // Backwards compatible for AC 2.9
87 if ( '' === $value ) {
88 $this->width = $value;
89
90 return true;
91 }
92
93 $value = absint( $value );
94
95 if ( $value > 0 ) {
96 $this->width = $value;
97
98 return true;
99 }
100
101 return false;
102 }
103
104 /**
105 * @return string
106 */
107 public function get_width_unit() {
108 return $this->width_unit;
109 }
110
111 /**
112 * @param string $width_unit
113 *
114 * @return bool
115 */
116 public function set_width_unit( $width_unit ) {
117 if ( ! $this->is_valid_width_unit( $width_unit ) ) {
118 return false;
119 }
120
121 $this->width_unit = $width_unit;
122
123 return true;
124 }
125
126 public function get_display_width() {
127 $value = false;
128
129 if ( $width = $this->get_width() ) {
130 $value = $width . $this->get_width_unit();
131 }
132
133 return $value;
134 }
135
136 }