コード例 #1
0
ファイル: helpers-html.php プロジェクト: wpscholar/wplib
 /**
  * Returns an HTML List of <li> elements, Ordered or Unordered
  *
  * @param string $list_element
  * @param string[] $li_elements
  * @param array $args {
  *      @type string $before
  *      @type string $class
  *      @type string[]|string $attributes
  *      @type string $before_elements
  *      @type string $before_li
  *      @type string $li_class
  *      @type string[]|string $li_attributes
  *      @type string $before_text
  *      @type string $after_text
  *      @type string $after_li
  *      @type string $after_elements
  *      @type string $after
  *      @type callable $filter
  * }
  * @return string
  */
 private static function _get_html_list_html($list_element, $li_elements, $args = array())
 {
     $args = wp_parse_args($args, array('before' => '', 'class' => '', 'attributes' => array(), 'before_elements' => '', 'before_li' => '', 'li_class' => '', 'li_attributes' => array(), 'before_text' => '', 'after_text' => '', 'after_li' => '', 'after_elements' => '', 'after' => '', 'filter' => null));
     $list_element = WPLib::sanitize_html_name($list_element);
     if (!empty($args['attributes']['class'])) {
         $args['class'] = esc_attr("{$args['attributes']['class']} {$args['class']}");
         unset($args['attributes']['class']);
     }
     $attributes = WPLib::get_html_attributes_html($args['attributes']);
     $list_html = self::get_html_li_elements_html($li_elements, array('before' => "{$args['before']}<{$list_element}{$attributes}" . " class=\"{$args['class']}\">{$args['before_elements']}", 'before_li' => $args['before_li'], 'class' => $args['li_class'], 'attributes' => $args['li_attributes'], 'before_text' => $args['before_text'], 'after_text' => $args['after_text'], 'after_li' => $args['after_li'], 'after' => "{$args['after_elements']}</{$list_element}>{$args['after']}", 'filter' => $args['filter']));
     return $list_html;
 }