Skip to content

Commit 2a1c8d2

Browse files
committed
Date Filter functionalities added
1 parent ffc4dab commit 2a1c8d2

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

components/DateFilter.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
namespace Tutor\Components;
1212

13-
use Tutor\Components\Constants\Size;
1413
use TUTOR\Icon;
1514
use TUTOR\Input;
15+
use Tutor\Components\Constants\Size;
1616

1717
if ( ! defined( 'ABSPATH' ) ) {
1818
exit;
@@ -91,7 +91,8 @@ class DateFilter extends BaseComponent {
9191
*/
9292
protected $icon_class;
9393

94-
/* Button size.
94+
/**
95+
* Button size.
9596
*
9697
* @var string
9798
*/
@@ -104,6 +105,15 @@ class DateFilter extends BaseComponent {
104105
*/
105106
protected $icon_size = 20;
106107

108+
/**
109+
* Whether to display the label text.
110+
*
111+
* @since 4.0.0
112+
*
113+
* @var bool
114+
*/
115+
protected $show_label = true;
116+
107117
/**
108118
* Set filter type.
109119
*
@@ -185,6 +195,19 @@ public function icon_class( string $icon_class ): self {
185195
return $this;
186196
}
187197

198+
/**
199+
* Enable or disable the display of the label text.
200+
*
201+
* @since 4.0.0
202+
*
203+
* @param bool $show_label True to show the label, false to hide it.
204+
* @return $this
205+
*/
206+
public function show_label( bool $show_label ) {
207+
$this->show_label = $show_label;
208+
return $this;
209+
}
210+
188211
/**
189212
* Render the component.
190213
*
@@ -292,6 +315,10 @@ protected function calculate_label(): string {
292315
return Input::get( 'date', '' );
293316
}
294317

318+
if ( ! $this->show_label ) {
319+
return '';
320+
}
321+
295322
$start_date = Input::get( 'start_date' );
296323
$end_date = Input::get( ( 'end_date' ) );
297324

0 commit comments

Comments
 (0)