Exemple #1
0
 /**
  * Add icon to menu title
  *
  * Icon types should override this method if they want to provide different markup.
  *
  * @since 0.1.0
  * @param string $title  Menu item title
  * @param array  $values Menu item metadata value
  *
  * @return string
  */
 protected function add_icon($title, $values)
 {
     if (empty($values['position'])) {
         $values['position'] = 'before';
     }
     $class = !empty($values['hide_label']) ? Menu_Icons::get_hidden_label_class() : '';
     $title = sprintf('<span%s>%s</span>', !empty($class) ? sprintf(' class="%s"', esc_attr($class)) : '', $title);
     $title = sprintf('%s<i class="_mi%s %s %s"%s></i>%s', 'before' === $values['position'] ? '' : $title, empty($values['hide_label']) ? esc_attr(" _{$values['position']}") : '', esc_attr($this->type), esc_attr($values[$this->key]), $this->get_style($values), 'after' === $values['position'] ? '' : $title);
     return $title;
 }
Exemple #2
0
 /**
  * Add icon to menu title
  *
  * @since  0.4.0
  * @access protected
  * @param  string $title  Menu item title.
  * @param  array  $values Menu item metadata value.
  *
  * @return string
  */
 protected function add_icon($title, $values)
 {
     $key = "{$this->type}-icon";
     if (empty($values[$key])) {
         return $title;
     }
     $icon = get_post($values[$key]);
     if (!$icon instanceof WP_Post || 'attachment' !== $icon->post_type) {
         return $title;
     }
     $t_class = !empty($values['hide_label']) ? Menu_Icons::get_hidden_label_class() : '';
     $title = sprintf('<span%s>%s</span>', !empty($t_class) ? sprintf(' class="%s"', esc_attr($t_class)) : '', $title);
     $i_class = '_mi';
     $i_class .= empty($values['hide_label']) ? " _{$values['position']}" : '';
     $i_style = $this->get_style($values);
     $i_attrs = array('class' => $i_class);
     if (!empty($i_style)) {
         $i_attrs['style'] = $i_style;
     }
     $title = sprintf('%s%s%s', 'before' === $values['position'] ? '' : $title, $this->get_icon_markup($icon->ID, $values, $i_attrs), 'after' === $values['position'] ? '' : $title);
     return $title;
 }