wp_popular_terms_checklist

Definition:
function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {}

Parameters

  • unknown_type $taxonomy
  • unknown_type $default
  • unknown_type $number
  • unknown_type $echo

Defined filters

  • the_category
    apply_filters( 'the_category', $term->name )

Source code

function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {

	global $post_ID;



	if ( $post_ID )

		$checked_terms = wp_get_object_terms($post_ID, $taxonomy, array('fields'=>'ids'));

	else

		$checked_terms = array();



	$terms = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );



	$tax = get_taxonomy($taxonomy);

	if ( ! current_user_can($tax->cap->assign_terms) )

		$disabled = 'disabled="disabled"';

	else

		$disabled = '';



	$popular_ids = array();

	foreach ( (array) $terms as $term ) {

		$popular_ids[] = $term->term_id;

		if ( !$echo ) // hack for AJAX use

			continue;

		$id = "popular-$taxonomy-$term->term_id";

		$checked = in_array( $term->term_id, $checked_terms ) ? 'checked="checked"' : '';

		?>



		<li id="<?php echo $id; ?>" class="popular-category">

			<label class="selectit">

			<input id="in-<?php echo $id; ?>" type="checkbox" <?php echo $checked; ?> value="<?php echo (int) $term->term_id; ?>" <?php echo $disabled ?>/>

				<?php echo esc_html( apply_filters( 'the_category', $term->name ) ); ?>

			</label>

		</li>



		<?php

	}

	return $popular_ids;

}

3987

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: