Array.php
8 years ago
Date.php
8 years ago
File.php
8 years ago
Html.php
8 years ago
Icon.php
8 years ago
Image.php
8 years ago
Network.php
8 years ago
Post.php
8 years ago
String.php
8 years ago
Taxonomy.php
8 years ago
User.php
8 years ago
Icon.php
74 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | class AC_Helper_Icon { |
| 8 | |
| 9 | public function dashicon( $args = array() ) { |
| 10 | $defaults = array( |
| 11 | 'icon' => '', |
| 12 | 'title' => '', |
| 13 | 'class' => '', |
| 14 | 'tooltip' => '', |
| 15 | ); |
| 16 | |
| 17 | $data = (object) wp_parse_args( $args, $defaults ); |
| 18 | |
| 19 | $class = 'dashicons dashicons-' . $data->icon; |
| 20 | |
| 21 | if ( $data->class ) { |
| 22 | $class .= ' ' . trim( $data->class ); |
| 23 | } |
| 24 | |
| 25 | $attributes = array(); |
| 26 | |
| 27 | if ( $data->title ) { |
| 28 | $attributes[] = 'title="' . esc_attr( $data->title ) . '"'; |
| 29 | } |
| 30 | |
| 31 | if ( $data->tooltip ) { |
| 32 | $attributes[] = ac_helper()->html->get_tooltip_attr( $data->tooltip ); |
| 33 | } |
| 34 | |
| 35 | return '<span class="' . esc_attr( $class ) . '" ' . implode( ' ', $attributes ) . '></span>'; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * @since 3.0 |
| 40 | * @return string |
| 41 | */ |
| 42 | public function yes( $tooltip = false, $title = true ) { |
| 43 | if ( true === $title ) { |
| 44 | $title = __( 'Yes' ); |
| 45 | } |
| 46 | |
| 47 | return $this->dashicon( array( 'icon' => 'yes', 'class' => 'green', 'title' => $title, 'tooltip' => $tooltip ) ); |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * @since 3.0 |
| 52 | * @return string |
| 53 | */ |
| 54 | public function no( $tooltip = false, $title = true ) { |
| 55 | if ( true === $title ) { |
| 56 | $title = __( 'No' ); |
| 57 | } |
| 58 | |
| 59 | return $this->dashicon( array( 'icon' => 'no', 'class' => 'red', 'title' => $title, 'tooltip' => $tooltip ) ); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * @since 3.0 |
| 64 | * |
| 65 | * @param bool $display |
| 66 | * |
| 67 | * @return string HTML Dashicon |
| 68 | */ |
| 69 | public function yes_or_no( $is_true, $tooltip = '' ) { |
| 70 | return $is_true ? $this->yes( $tooltip ) : $this->no( $tooltip ); |
| 71 | } |
| 72 | |
| 73 | } |
| 74 |