wp_link_category_checklist

Definition:
function wp_link_category_checklist( $link_id = 0 ) {}

Parameters

  • unknown_type $link_id

Defined filters

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

Source code

function wp_link_category_checklist( $link_id = 0 ) {

	$default = 1;



	if ( $link_id ) {

		$checked_categories = wp_get_link_cats( $link_id );

		// No selected categories, strange

		if ( ! count( $checked_categories ) )

			$checked_categories[] = $default;

	} else {

		$checked_categories[] = $default;

	}



	$categories = get_terms( 'link_category', array( 'orderby' => 'name', 'hide_empty' => 0 ) );



	if ( empty( $categories ) )

		return;



	foreach ( $categories as $category ) {

		$cat_id = $category->term_id;

		$name = esc_html( apply_filters( 'the_category', $category->name ) );

		$checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : '';

		echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', $checked, '/> ', $name, "</label></li>";

	}

}

3849

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: