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
125      );
126
127      $r = wp_parse_args( $args, $defaults );
128      extract( $r, EXTR_SKIP );
129
130      $cache = array();
131      $key = md5( serialize( $r ) );
132      if ( $cache = wp_cache_get( 'get_bookmarks', 'bookmark' ) ) {
133           if ( is_array($cache) && isset( $cache[ $key ] ) )
134                return apply_filters('get_bookmarks', $cache[ $key ], $r );
135      }
136
137      if ( !is_array($cache) )
138           $cache = array();
139
140      $inclusions = '';
141      if ( !empty($include) ) {
142           $exclude = '';  //ignore exclude, category, and category_name params if using include
143           $category = '';
 
Line Code
170      if (!empty($exclusions))
171           $exclusions .= ')';
172
173      if ( !empty($category_name) ) {
174           if ( $category = get_term_by('name', $category_name, 'link_category') ) {
175                $category = $category->term_id;
176           } else {
177                $cache[ $key ] = array();
178                wp_cache_set( 'get_bookmarks', $cache, 'bookmark' );
179                return apply_filters( 'get_bookmarks', array(), $r );
180           }
181      }
182
183      if ( ! empty($search) ) {
184           $search = like_escape($search);
185           $search = " AND ( (link_url LIKE '%$search%') OR (link_name LIKE '%$search%') OR (link_description LIKE '%$search%') ) ";
186      }
187
188      $category_query = '';
 
Line Code
249      $query .= " ORDER BY $orderby $order";
250      if ($limit != -1)
251           $query .= " LIMIT $limit";
252
253      $results = $wpdb->get_results($query);
254
255      $cache[ $key ] = $results;
256      wp_cache_set( 'get_bookmarks', $cache, 'bookmark' );
257
258      return apply_filters('get_bookmarks', $results, $r);
259 }
260
261 /**
262  * Sanitizes all bookmark fields
263  *
264  * @since 2.3.0
265  *
266  * @param object|array $bookmark Bookmark row
267  * @param string $context Optional, default is 'display'. How to filter the