Image
4 days ago
Select
4 days ago
Arrays.php
4 days ago
AvailableTranslations.php
4 days ago
Creatable.php
4 days ago
Dashicon.php
4 days ago
Date.php
4 days ago
Html.php
4 days ago
Icon.php
4 days ago
Image.php
4 days ago
LocalFile.php
4 days ago
Mbstring.php
4 days ago
MediaIdResolver.php
4 days ago
Menu.php
4 days ago
Network.php
4 days ago
Post.php
4 days ago
Strings.php
4 days ago
Taxonomy.php
4 days ago
User.php
4 days ago
UserRoles.php
4 days ago
WpDateFormat.php
4 days ago
Icon.php
47 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Helper; |
| 6 | |
| 7 | /** |
| 8 | * @deprecated 7.0.14 Use {@see Dashicon} instead. Will be removed in 7.1. |
| 9 | */ |
| 10 | class Icon extends Creatable |
| 11 | { |
| 12 | public function dashicon(array $args = []): string |
| 13 | { |
| 14 | $defaults = [ |
| 15 | 'icon' => '', |
| 16 | 'title' => '', |
| 17 | 'class' => '', |
| 18 | 'tooltip' => '', |
| 19 | ]; |
| 20 | |
| 21 | $data = (object)wp_parse_args($args, $defaults); |
| 22 | |
| 23 | return (new Dashicon( |
| 24 | (string)$data->icon, |
| 25 | (string)$data->class, |
| 26 | '' !== (string)$data->title ? (string)$data->title : null, |
| 27 | is_string($data->tooltip) && '' !== $data->tooltip ? $data->tooltip : null |
| 28 | ))->render(); |
| 29 | } |
| 30 | |
| 31 | public function yes(?string $tooltip = null, ?string $title = null, ?string $class = null): string |
| 32 | { |
| 33 | return Dashicon::yes($tooltip, $title, $class ?: 'green')->render(); |
| 34 | } |
| 35 | |
| 36 | public function no(?string $tooltip = null, ?string $title = null, ?string $class = 'red'): string |
| 37 | { |
| 38 | return Dashicon::no($tooltip, $title, $class)->render(); |
| 39 | } |
| 40 | |
| 41 | public function yes_or_no(bool $is_true, ?string $tooltip = null): string |
| 42 | { |
| 43 | return Dashicon::yes_or_no($is_true, $tooltip)->render(); |
| 44 | } |
| 45 | |
| 46 | } |
| 47 |