<?php
/*
* This file is called by templates/forms/location-editor.php to display fields for uploading images on your event form on your website. This does not affect the admin featured image section.
* You can override this file by copying it to /wp-content/themes/yourtheme/plugins/events-manager/forms/event/ and editing it there.
*/
global $EM_Event;
/* @var $EM_Event EM_Event */
$categories = EM_Categories::get(array('orderby' => 'name', 'hide_empty' => 0));
if (count($categories) > 0) {
?>
<div class="event-categories">
<!-- START Categories -->
<label for="event_categories[]"><?php
_e('Category:', 'dbem');
?>
</label>
<select name="event_categories[]" multiple size="10">
<?php
$selected = $EM_Event->get_categories()->get_ids();
$walker = new EM_Walker_CategoryMultiselect();
$args_em = array('hide_empty' => 0, 'name' => 'event_categories[]', 'hierarchical' => true, 'id' => EM_TAXONOMY_CATEGORY, 'taxonomy' => EM_TAXONOMY_CATEGORY, 'selected' => $selected, 'walker' => $walker);
echo walk_category_dropdown_tree($categories, 0, $args_em);
?>
</select>
<!-- END Categories -->
</div>
<?php
}
/**
* Display or retrieve the HTML dropdown list of categories.
*
* The list of arguments is below:
* 'show_option_all' (string) - Text to display for showing all categories.
* 'show_option_none' (string) - Text to display for showing no categories.
* 'orderby' (string) default is 'ID' - What column to use for ordering the
* categories.
* 'order' (string) default is 'ASC' - What direction to order categories.
* 'show_last_update' (bool|int) default is 0 - See {@link get_categories()}
* 'show_count' (bool|int) default is 0 - Whether to show how many posts are
* in the category.
* 'hide_empty' (bool|int) default is 1 - Whether to hide categories that
* don't have any posts attached to them.
* 'child_of' (int) default is 0 - See {@link get_categories()}.
* 'exclude' (string) - See {@link get_categories()}.
* 'echo' (bool|int) default is 1 - Whether to display or retrieve content.
* 'depth' (int) - The max depth.
* 'tab_index' (int) - Tab index for select element.
* 'name' (string) - The name attribute value for selected element.
* 'class' (string) - The class attribute value for selected element.
* 'selected' (int) - Which category ID is selected.
*
* The 'hierarchical' argument, which is disabled by default, will override the
* depth argument, unless it is true. When the argument is false, it will
* display all of the categories. When it is enabled it will use the value in
* the 'depth' argument.
*
* @since 2.1.0
*
* @param string|array $args Optional. Override default arguments.
* @return string HTML content only if 'echo' argument is 0.
*/
function avh_wp_dropdown_categories($args = '', $selectedonly)
{
$mywalker = new AVH_Walker_CategoryDropdown();
$defaults = array('show_option_all' => '', 'show_option_none' => '', 'orderby' => 'id', 'order' => 'ASC', 'show_last_update' => 0, 'show_count' => 0, 'hide_empty' => 1, 'child_of' => 0, 'exclude' => '', 'echo' => 1, 'selected' => 0, 'hierarchical' => 0, 'name' => 'cat', 'class' => 'postform', 'depth' => 0, 'tab_index' => 0, 'walker' => $mywalker);
$defaults['selected'] = is_category() ? get_query_var('cat') : 0;
$r = wp_parse_args($args, $defaults);
if (!isset($r['pad_counts']) && $r['show_count'] && $r['hierarchical']) {
$r['pad_counts'] = true;
}
$r['include_last_update_time'] = $r['show_last_update'];
extract($r);
$tab_index_attribute = '';
if ((int) $tab_index > 0) {
$tab_index_attribute = ' tabindex="' . $tab_index . '"';
}
$categories = get_categories($r);
$name = esc_attr($name);
$class = esc_attr($class);
$output = '';
if (!empty($categories)) {
$output = '<select name="' . $name . '" id="' . $name . '" class="' . $class . '" ' . $tab_index_attribute . '>' . "\n";
if ($show_option_all) {
$show_option_all = apply_filters('list_cats', $show_option_all);
$selected = '0' === strval($r['selected']) ? " selected='selected'" : '';
$output .= "\t" . '<option value="0"' . $selected . '>' . $show_option_all . '</option>' . "\n";
}
if ($show_option_none) {
$show_option_none = apply_filters('list_cats', $show_option_none);
$selected = '-1' === strval($r['selected']) ? " selected='selected'" : '';
$output .= "\t" . '<option value="-1"' . $selected . '>' . $show_option_none . '</option>' . "\n";
}
if ($hierarchical) {
$depth = $r['depth'];
// Walk the full depth.
} else {
$depth = -1;
// Flat
}
$output .= walk_category_dropdown_tree($categories, $depth, $r);
$output .= "</select>\n";
}
$output = apply_filters('wp_dropdown_cats', $output);
if ($echo) {
echo $output;
}
return $output;
}
/**
* Display or retrieve the HTML dropdown list of categories.
*
* The list of arguments is below:
* 'show_option_all' (string) - Text to display for showing all categories.
* 'show_option_none' (string) - Text to display for showing no categories.
* 'orderby' (string) default is 'ID' - What column to use for ordering the
* categories.
* 'order' (string) default is 'ASC' - What direction to order categories.
* 'show_count' (bool|int) default is 0 - Whether to show how many posts are
* in the category.
* 'hide_empty' (bool|int) default is 1 - Whether to hide categories that
* don't have any posts attached to them.
* 'child_of' (int) default is 0 - See {@link get_categories()}.
* 'exclude' (string) - See {@link get_categories()}.
* 'echo' (bool|int) default is 1 - Whether to display or retrieve content.
* 'depth' (int) - The max depth.
* 'tab_index' (int) - Tab index for select element.
* 'name' (string) - The name attribute value for select element.
* 'id' (string) - The ID attribute value for select element. Defaults to name if omitted.
* 'class' (string) - The class attribute value for select element.
* 'selected' (int) - Which category ID is selected.
* 'taxonomy' (string) - The name of the taxonomy to retrieve. Defaults to category.
*
* The 'hierarchical' argument, which is disabled by default, will override the
* depth argument, unless it is true. When the argument is false, it will
* display all of the categories. When it is enabled it will use the value in
* the 'depth' argument.
*
* @since 2.1.0
*
* @param string|array $args Optional. Override default arguments.
* @return string HTML content only if 'echo' argument is 0.
*/
function wp_dropdown_categories($args = '')
{
$defaults = array('show_option_all' => '', 'show_option_none' => '', 'orderby' => 'id', 'order' => 'ASC', 'show_count' => 0, 'hide_empty' => 1, 'child_of' => 0, 'exclude' => '', 'echo' => 1, 'selected' => 0, 'hierarchical' => 0, 'name' => 'cat', 'id' => '', 'class' => 'postform', 'depth' => 0, 'tab_index' => 0, 'taxonomy' => 'category', 'hide_if_empty' => false);
$defaults['selected'] = is_category() ? get_query_var('cat') : 0;
// Back compat.
if (isset($args['type']) && 'link' == $args['type']) {
_deprecated_argument(__FUNCTION__, '3.0', '');
$args['taxonomy'] = 'link_category';
}
$r = wp_parse_args($args, $defaults);
if (!isset($r['pad_counts']) && $r['show_count'] && $r['hierarchical']) {
$r['pad_counts'] = true;
}
extract($r);
$tab_index_attribute = '';
if ((int) $tab_index > 0) {
$tab_index_attribute = " tabindex=\"{$tab_index}\"";
}
$categories = get_terms($taxonomy, $r);
$name = esc_attr($name);
$class = esc_attr($class);
$id = $id ? esc_attr($id) : $name;
if (!$r['hide_if_empty'] || !empty($categories)) {
$output = "<select name='{$name}' id='{$id}' class='{$class}' {$tab_index_attribute}>\n";
} else {
$output = '';
}
if (empty($categories) && !$r['hide_if_empty'] && !empty($show_option_none)) {
$show_option_none = apply_filters('list_cats', $show_option_none);
$output .= "\t<option value='-1' selected='selected'>{$show_option_none}</option>\n";
}
if (!empty($categories)) {
if ($show_option_all) {
$show_option_all = apply_filters('list_cats', $show_option_all);
$selected = '0' === strval($r['selected']) ? " selected='selected'" : '';
$output .= "\t<option value='0'{$selected}>{$show_option_all}</option>\n";
}
if ($show_option_none) {
$show_option_none = apply_filters('list_cats', $show_option_none);
$selected = '-1' === strval($r['selected']) ? " selected='selected'" : '';
$output .= "\t<option value='-1'{$selected}>{$show_option_none}</option>\n";
}
if ($hierarchical) {
$depth = $r['depth'];
} else {
$depth = -1;
}
// Flat.
$output .= walk_category_dropdown_tree($categories, $depth, $r);
}
if (!$r['hide_if_empty'] || !empty($categories)) {
$output .= "</select>\n";
}
$output = apply_filters('wp_dropdown_cats', $output);
if ($echo) {
echo $output;
}
return $output;
}
/**
* Display or retrieve the HTML dropdown list of categories.
*
* The list of arguments is below:
* 'show_option_all' (string) - Text to display for showing all categories.
* 'show_option_none' (string) - Text to display for showing no categories.
* 'orderby' (string) default is 'ID' - What column to use for ordering the
* categories.
* 'order' (string) default is 'ASC' - What direction to order categories.
* 'show_last_update' (bool|int) default is 0 - See {@link get_categories()}
* 'show_count' (bool|int) default is 0 - Whether to show how many posts are
* in the category.
* 'hide_empty' (bool|int) default is 1 - Whether to hide categories that
* don't have any posts attached to them.
* 'child_of' (int) default is 0 - See {@link get_categories()}.
* 'exclude' (string) - See {@link get_categories()}.
* 'echo' (bool|int) default is 1 - Whether to display or retrieve content.
* 'depth' (int) - The max depth.
* 'tab_index' (int) - Tab index for select element.
* 'name' (string) - The name attribute value for selected element.
* 'class' (string) - The class attribute value for selected element.
* 'selected' (int) - Which category ID is selected.
*
* The 'hierarchical' argument, which is disabled by default, will override the
* depth argument, unless it is true. When the argument is false, it will
* display all of the categories. When it is enabled it will use the value in
* the 'depth' argument.
*
* @since 2.1.0
*
* @param string|array $args Optional. Override default arguments.
* @return string HTML content only if 'echo' argument is 0.
*/
function wp_dropdown_categories( $args = '' ) {
$defaults = array(
'show_option_all' => '', 'show_option_none' => '',
'orderby' => 'ID', 'order' => 'ASC',
'show_last_update' => 0, 'show_count' => 0,
'hide_empty' => 1, 'child_of' => 0,
'exclude' => '', 'echo' => 1,
'selected' => 0, 'hierarchical' => 0,
'name' => 'cat', 'class' => 'postform',
'depth' => 0, 'tab_index' => 0
);
$defaults['selected'] = ( is_category() ) ? get_query_var( 'cat' ) : 0;
$r = wp_parse_args( $args, $defaults );
$r['include_last_update_time'] = $r['show_last_update'];
extract( $r );
$tab_index_attribute = '';
if ( (int) $tab_index > 0 )
$tab_index_attribute = " tabindex=\"$tab_index\"";
$categories = get_categories( $r );
$output = '';
if ( ! empty( $categories ) ) {
$output = "<select name='$name' id='$name' class='$class' $tab_index_attribute>\n";
if ( $show_option_all ) {
$show_option_all = apply_filters( 'list_cats', $show_option_all );
$output .= "\t<option value='0'>$show_option_all</option>\n";
}
if ( $show_option_none ) {
$show_option_none = apply_filters( 'list_cats', $show_option_none );
$output .= "\t<option value='-1'>$show_option_none</option>\n";
}
if ( $hierarchical )
$depth = $r['depth']; // Walk the full depth.
else
$depth = -1; // Flat.
$output .= walk_category_dropdown_tree( $categories, $depth, $r );
$output .= "</select>\n";
}
$output = apply_filters( 'wp_dropdown_cats', $output );
if ( $echo )
echo $output;
return $output;
}
请发表评论