function display_rows()
    {
        global $cat_id;
        $alt = 0;
        foreach ($this->items as $link) {
            $link = sanitize_bookmark($link);
            $link->link_name = esc_attr($link->link_name);
            $link->link_category = nxt_get_link_cats($link->link_id);
            $short_url = url_shorten($link->link_url);
            $visible = $link->link_visible == 'Y' ? __('Yes') : __('No');
            $rating = $link->link_rating;
            $style = $alt++ % 2 ? '' : ' class="alternate"';
            $edit_link = get_edit_bookmark_link($link);
            ?>
		<tr id="link-<?php 
            echo $link->link_id;
            ?>
" valign="middle" <?php 
            echo $style;
            ?>
>
<?php 
            list($columns, $hidden) = $this->get_column_info();
            foreach ($columns as $column_name => $column_display_name) {
                $class = "class='column-{$column_name}'";
                $style = '';
                if (in_array($column_name, $hidden)) {
                    $style = ' style="display:none;"';
                }
                $attributes = $class . $style;
                switch ($column_name) {
                    case 'cb':
                        echo '<th scope="row" class="check-column"><input type="checkbox" name="linkcheck[]" value="' . esc_attr($link->link_id) . '" /></th>';
                        break;
                    case 'name':
                        echo "<td {$attributes}><strong><a class='row-title' href='{$edit_link}' title='" . esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $link->link_name)) . "'>{$link->link_name}</a></strong><br />";
                        $actions = array();
                        $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
                        $actions['delete'] = "<a class='submitdelete' href='" . nxt_nonce_url("link.php?action=delete&amp;link_id={$link->link_id}", 'delete-bookmark_' . $link->link_id) . "' onclick=\"if ( confirm( '" . esc_js(sprintf(__("You are about to delete this link '%s'\n  'Cancel' to stop, 'OK' to delete."), $link->link_name)) . "' ) ) { return true;}return false;\">" . __('Delete') . "</a>";
                        echo $this->row_actions($actions);
                        echo '</td>';
                        break;
                    case 'url':
                        echo "<td {$attributes}><a href='{$link->link_url}' title='" . esc_attr(sprintf(__('Visit %s'), $link->link_name)) . "'>{$short_url}</a></td>";
                        break;
                    case 'categories':
                        ?>
<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        $cat_names = array();
                        foreach ($link->link_category as $category) {
                            $cat = get_term($category, 'link_category', OBJECT, 'display');
                            if (is_nxt_error($cat)) {
                                echo $cat->get_error_message();
                            }
                            $cat_name = $cat->name;
                            if ($cat_id != $category) {
                                $cat_name = "<a href='link-manager.php?cat_id={$category}'>{$cat_name}</a>";
                            }
                            $cat_names[] = $cat_name;
                        }
                        echo implode(', ', $cat_names);
                        ?>
</td><?php 
                        break;
                    case 'rel':
                        ?>
<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo empty($link->link_rel) ? '<br />' : $link->link_rel;
                        ?>
</td><?php 
                        break;
                    case 'visible':
                        ?>
<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo $visible;
                        ?>
</td><?php 
                        break;
                    case 'rating':
                        ?>
<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo $rating;
                        ?>
</td><?php 
                        break;
                    default:
                        ?>
						<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        do_action('manage_link_custom_column', $column_name, $link->link_id);
                        ?>
</td>
						<?php 
                        break;
                }
            }
            ?>
		</tr>
<?php 
        }
    }
Exemple #2
0
/**
 * Gets the name of category by id.
 *
 * @since 0.71
 * @deprecated 2.1
 * @deprecated Use get_category()
 * @see get_category()
 *
 * @param int $id The category to get. If no category supplied uses 0
 * @return string
 */
function get_linkcatname($id = 0)
{
    _deprecated_function(__FUNCTION__, '2.1', 'get_category()');
    $id = (int) $id;
    if (empty($id)) {
        return '';
    }
    $cats = nxt_get_link_cats($id);
    if (empty($cats) || !is_array($cats)) {
        return '';
    }
    $cat_id = (int) $cats[0];
    // Take the first cat.
    $cat = get_category($cat_id);
    return $cat->name;
}
Exemple #3
0
/**
 * {@internal Missing Short Description}}
 *
 * @since 2.5.1
 *
 * @param unknown_type $link_id
 */
function nxt_link_category_checklist($link_id = 0)
{
    $default = 1;
    if ($link_id) {
        $checked_categories = nxt_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>";
    }
}