| 1 |
<?php |
| 2 |
/** |
| 3 |
* FeedWordPress_Walker_Category_Checklist |
| 4 |
* |
| 5 |
* @version 2010.0531 |
| 6 |
* |
| 7 |
* This is the fucking stupidest thing ever. |
| 8 |
*/ |
| 9 |
|
| 10 |
require_once(ABSPATH.'/wp-admin/includes/template.php'); |
| 11 |
// Fucking fuck. |
| 12 |
|
| 13 |
class FeedWordPress_Walker_Category_Checklist extends Walker_Category_Checklist { |
| 14 |
var $prefix = ''; var $taxonomy = 'category'; |
| 15 |
var $checkbox_name = NULL; |
| 16 |
function FeedWordPress_Walker_Category_Checklist ($params = array()) { |
| 17 |
$this->set_taxonomy('category'); |
| 18 |
|
| 19 |
if (isset($params['checkbox_name'])) : |
| 20 |
$this->checkbox_name = $params['checkbox_name']; |
| 21 |
endif; |
| 22 |
} |
| 23 |
|
| 24 |
function set_prefix ($prefix) { |
| 25 |
$this->prefix = $prefix; |
| 26 |
} |
| 27 |
function set_taxonomy ($taxonomy) { |
| 28 |
$this->taxonomy = $taxonomy; |
| 29 |
} |
| 30 |
|
| 31 |
function start_el (&$output, $category, $depth, $args) { |
| 32 |
extract($args); |
| 33 |
if ( empty($taxonomy) ) : |
| 34 |
$taxonomy = 'category'; |
| 35 |
endif; |
| 36 |
|
| 37 |
if (!is_null($this->checkbox_name)) : |
| 38 |
$name = $this->checkbox_name; |
| 39 |
elseif ($taxonomy=='category') : |
| 40 |
$name = 'post_category'; |
| 41 |
else : |
| 42 |
$name = 'tax_input['.$taxonomy.']'; |
| 43 |
endif; |
| 44 |
|
| 45 |
$unit = array(); |
| 46 |
if (strlen($this->prefix) > 0) : |
| 47 |
$unit[] = $this->prefix; |
| 48 |
endif; |
| 49 |
$unit[] = $taxonomy; |
| 50 |
$unit[] = $category->term_id; |
| 51 |
$unitId = implode("-", $unit); |
| 52 |
|
| 53 |
$class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category category-checkbox"' : ' class="category-checkbox"'; |
| 54 |
$output .= "\n<li id='{$unitId}'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$unitId. '"' . checked( in_array( $category->term_id, $selected_cats ), true, false ) . disabled( empty( $args['disabled'] ), false, false ) . ' /> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>'; |
| 55 |
} /* FeedWordPress_Walker_Category_Checklist::start_el() */ |
| 56 |
} /* FeedWordPress_Walker_Category_Checklist */ |
| 57 |
|