Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: get_bookmarks

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 3 times in this file.

Line Code
130      );
131
132      $r = wp_parse_args( $args, $defaults );
133      extract( $r, EXTR_SKIP );
134
135      $cache = array();
136      $key = md5( serialize( $r ) );
137      if ( $cache = wp_cache_get( 'get_bookmarks', 'bookmark' ) ) {
138           if ( is_array($cache) && isset( $cache[ $key ] ) )
139                return apply_filters('get_bookmarks', $cache[ $key ], $r );
140      }
141
142      if ( !is_array($cache) )
143           $cache = array();
144
145      $inclusions = '';
146      if ( !empty($include) ) {
147           $exclude = '';  //ignore exclude, category, and category_name params if using include
148           $category = '';
 
Line Code
175      if (!empty($exclusions))
176           $exclusions .= ')';
177
178      if ( !empty($category_name) ) {
179           if ( $category = get_term_by('name', $category_name, 'link_category') ) {
180                $category = $category->term_id;
181           } else {
182                $cache[ $key ] = array();
183                wp_cache_set( 'get_bookmarks', $cache, 'bookmark' );
184                return apply_filters( 'get_bookmarks', array(), $r );
185           }
186      }
187
188      if ( ! empty($search) ) {
189           $search = like_escape($search);
190           $search = " AND ( (link_url LIKE '%$search%') OR (link_name LIKE '%$search%') OR (link_description LIKE '%$search%') ) ";
191      }
192
193      $category_query = '';
 
Line Code
257      $query .= " ORDER BY $orderby $order";
258      if ($limit != -1)
259           $query .= " LIMIT $limit";
260
261      $results = $wpdb->get_results($query);
262
263      $cache[ $key ] = $results;
264      wp_cache_set( 'get_bookmarks', $cache, 'bookmark' );
265
266      return apply_filters('get_bookmarks', $results, $r);
267 }
268
269 /**
270  * Sanitizes all bookmark fields
271  *
272  * @since 2.3.0
273  *
274  * @param object|array $bookmark Bookmark row
275  * @param string $context Optional, default is 'display'. How to filter the