get_links_list( string $order = 'name' )
- Since
- 1.0.1
- Source
wp-includes/deprecated.php:1040
Description
Output a list of all links, listed by category, using the settings in $wpdb->linkcategories and output it as a nested HTML unordered list.
Compatibility
Deprecated in WordPress 2.1.0. Use wp_list_bookmarks()
- WordPress
- since 1.0.1
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$orderstringoptional- Sort link categories by 'name' or 'id'Default:
'name'
Performance profile
How much work a call to get_links_list() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Heavy
- Scaling
- Scales with input
- Instructions
- 25–33
- Plugin surface
- 1 hook
- Called by
- 0
Reaches the database via get_terms().
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 58.
Third-party callbacks on 'link_category' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()called directly - querycontent query
get_terms()one call below get_links_list() - optionoption read or write
get_option()one call below get_links_list()
Further down the call graph this can also reach cache, serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost get_links_list() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 25–33 | _deprecated_function(), strtolower(), link() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 58 | 25–33 | 5 | |
| 8.5 | 58 | 25–33 | 5 | |
| 8.4 | 58 | 25–33 | 5 | 6 fewer instructions than PHP 8.3 |
| 8.3 | 64 | 28–39 | 5 | |
| 8.2 | 64 | 28–39 | 5 | |
| 8.1 | 64 | 28–39 | 5 | |
| 7.4 | 64 | 28–39 | 5 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Hooks and filters fired · 1
One hook fires while get_links_list() runs, in this order:
Uses · 5
- _deprecated_function()Marks a function as deprecated and inform when it has been used.
- str_starts_with()Polyfill for `str_starts_with()` function added in PHP 8.0.
- get_categories()Retrieves a list of category objects.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- get_links()Gets the links associated with category by ID.
Source code
function get_links_list($order = 'name') { _deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_bookmarks()' ); $order = strtolower($order); // Handle link category sorting. $direction = 'ASC'; if ( str_starts_with( $order, '_' ) ) { $direction = 'DESC'; $order = substr($order,1); } if ( !isset($direction) ) $direction = ''; $cats = get_categories(array('type' => 'link', 'orderby' => $order, 'order' => $direction, 'hierarchical' => 0)); // Display each category. if ( $cats ) { foreach ( (array) $cats as $cat ) { // Handle each category. // Display the category name. echo ' <li id="linkcat-' . $cat->term_id . '" class="linkcat"><h2>' . apply_filters('link_category', $cat->name ) . "</h2>\n\t<ul>\n"; // Call get_links() with all the appropriate params. get_links($cat->term_id, '<li>', "</li>", "\n", true, 'name', false); // Close the last category. echo "\n\t</ul>\n</li>\n"; } }}Changelog
Introduced in 1.0.1. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-includes/deprecated.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.