Welcome, visitor! Log in
 

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.

  • Action hooks look like this: do_action( "hook_name" )
  • Filter hooks look like this: apply_filters( "hook_name", "what_to_filter" ).

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
140      );
141
142      $r = wp_parse_args( $args, $defaults );
143      extract( $r, EXTR_SKIP );
144
145      $cache = array();
146      $key = md5( serialize( $r ) );
147      if ( $cache = wp_cache_get( 'get_bookmarks', 'bookmark' ) ) {
148           if ( is_array($cache) && isset( $cache[ $key ] ) )
149                return apply_filters('get_bookmarks', $cache[ $key ], $r );
150      }
151
152      if ( !is_array($cache) )
153           $cache = array();
154
155      $inclusions = '';
156      if ( !empty($include) ) {
157           $exclude = '';  //ignore exclude, category, and category_name params if using include
158           $category = '';
 
Line Code
185      if (!empty($exclusions))
186           $exclusions .= ')';
187
188      if ( !empty($category_name) ) {
189           if ( $category = get_term_by('name', $category_name, 'link_category') ) {
190                $category = $category->term_id;
191           } else {
192                $cache[ $key ] = array();
193                wp_cache_set( 'get_bookmarks', $cache, 'bookmark' );
194                return apply_filters( 'get_bookmarks', array(), $r );
195           }
196      }
197
198      if ( ! empty($search) ) {
199           $search = like_escape($search);
200           $search = " AND ( (link_url LIKE '%$search%') OR (link_name LIKE '%$search%') OR (link_description LIKE '%$search%') ) ";
201      }
202
203      $category_query = '';
 
Line Code
251      $query .= " ORDER BY $orderby $order";
252      if ($limit != -1)
253           $query .= " LIMIT $limit";
254
255      $results = $wpdb->get_results($query);
256
257      $cache[ $key ] = $results;
258      wp_cache_set( 'get_bookmarks', $cache, 'bookmark' );
259
260      return apply_filters('get_bookmarks', $results, $r);
261 }
262
263 /**
264  * Sanitizes all bookmark fields
265  *
266  * @since 2.3.0
267  *
268  * @param object|array $bookmark Bookmark row
269  * @param string $context Optional, default is 'display'. How to filter the