wp_link_category_checklist

The timeline below displays how wordpress function wp_link_category_checklist has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.2

/**
 * Outputs a link category checklist element.
 *
 * @since 2.5.1
 *
 * @param int $link_id Optional. The link ID. Default 0.
 */
function wp_link_category_checklist($link_id = 0)
{
    $default = 1;
    $checked_categories = array();
    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(array('taxonomy' => 'link_category', 'orderby' => 'name', 'hide_empty' => 0));
    if (empty($categories)) {
        return;
    }
    foreach ($categories as $category) {
        $cat_id = $category->term_id;
        /** This filter is documented in wp-includes/category-template.php */
        $name = esc_html(apply_filters('the_category', $category->name, '', ''));
        $checked = in_array($cat_id, $checked_categories, true) ? ' 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>';
    }
}

WordPress Version: 5.5

/**
 * Outputs a link category checklist element.
 *
 * @since 2.5.1
 *
 * @param int $link_id
 */
function wp_link_category_checklist($link_id = 0)
{
    $default = 1;
    $checked_categories = array();
    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(array('taxonomy' => 'link_category', 'orderby' => 'name', 'hide_empty' => 0));
    if (empty($categories)) {
        return;
    }
    foreach ($categories as $category) {
        $cat_id = $category->term_id;
        /** This filter is documented in wp-includes/category-template.php */
        $name = esc_html(apply_filters('the_category', $category->name, '', ''));
        $checked = in_array($cat_id, $checked_categories, true) ? ' 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>';
    }
}

WordPress Version: 5.4

/**
 * Outputs a link category checklist element.
 *
 * @since 2.5.1
 *
 * @param int $link_id
 */
function wp_link_category_checklist($link_id = 0)
{
    $default = 1;
    $checked_categories = array();
    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(array('taxonomy' => 'link_category', 'orderby' => 'name', 'hide_empty' => 0));
    if (empty($categories)) {
        return;
    }
    foreach ($categories as $category) {
        $cat_id = $category->term_id;
        /** This filter is documented in wp-includes/category-template.php */
        $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>';
    }
}

WordPress Version: 5.3

/**
 * Outputs a link category checklist element.
 *
 * @since 2.5.1
 *
 * @param int $link_id
 */
function wp_link_category_checklist($link_id = 0)
{
    $default = 1;
    $checked_categories = array();
    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(array('taxonomy' => 'link_category', 'orderby' => 'name', 'hide_empty' => 0));
    if (empty($categories)) {
        return;
    }
    foreach ($categories as $category) {
        $cat_id = $category->term_id;
        /** This filter is documented in wp-includes/category-template.php */
        $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>';
    }
}

WordPress Version: 5.1

/**
 * Outputs a link category checklist element.
 *
 * @since 2.5.1
 *
 * @param int $link_id
 */
function wp_link_category_checklist($link_id = 0)
{
    $default = 1;
    $checked_categories = array();
    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;
        /** This filter is documented in wp-includes/category-template.php */
        $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>';
    }
}

WordPress Version: 4.9

/**
 * Outputs a link category checklist element.
 *
 * @since 2.5.1
 *
 * @param int $link_id
 */
function wp_link_category_checklist($link_id = 0)
{
    $default = 1;
    $checked_categories = array();
    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;
        /** This filter is documented in wp-includes/category-template.php */
        $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>";
    }
}

WordPress Version: 4.4

/**
 * Outputs a link category checklist element.
 *
 * @since 2.5.1
 *
 * @param int $link_id
 */
function wp_link_category_checklist($link_id = 0)
{
    $default = 1;
    $checked_categories = array();
    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;
        /** This filter is documented in wp-includes/category-template.php */
        $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>";
    }
}

WordPress Version: 4.2

/**
 * {@internal Missing Short Description}}
 *
 * @since 2.5.1
 *
 * @param int $link_id
 */
function wp_link_category_checklist($link_id = 0)
{
    $default = 1;
    $checked_categories = array();
    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;
        /** This filter is documented in wp-includes/category-template.php */
        $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>";
    }
}

WordPress Version: 4.1

/**
 * {@internal Missing Short Description}}
 *
 * @since 2.5.1
 *
 * @param int $link_id
 */
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;
        /** This filter is documented in wp-includes/category-template.php */
        $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>";
    }
}

WordPress Version: 3.9

/**
 * {@internal Missing Short Description}}
 *
 * @since 2.5.1
 *
 * @param unknown_type $link_id
 */
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;
        /** This filter is documented in wp-includes/category-template.php */
        $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>";
    }
}

WordPress Version: 3.7

/**
 * {@internal Missing Short Description}}
 *
 * @since 2.5.1
 *
 * @param unknown_type $link_id
 */
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>";
    }
}