Changeset 3589 for trunk/wp-includes/links.php
- Timestamp:
- 03/02/2006 03:27:48 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/links.php
r3570 r3589 1 1 <?php 2 3 /** function get_linksbyname()4 ** Gets the links associated with category 'cat_name'.5 ** Parameters:6 ** cat_name (default 'noname') - The category name to use. If no7 ** match is found uses all8 ** before (default '') - the html to output before the link9 ** after (default '<br />') - the html to output after the link10 ** between (default ' ') - the html to output between the link/image11 ** and it's description. Not used if no image or show_images == true12 ** show_images (default true) - whether to show images (if defined).13 ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',14 ** 'url', 'description' or 'rating'. Or maybe owner. If you start the15 ** name with an underscore the order will be reversed.16 ** You can also specify 'rand' as the order which will return links in a17 ** random order.18 ** show_description (default true) - whether to show the description if19 ** show_images=false/not defined20 ** show_rating (default false) - show rating stars/chars21 ** limit (default -1) - Limit to X entries. If not specified, all entries22 ** are shown.23 ** show_updated (default 0) - whether to show last updated timestamp24 */25 function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />',26 $between = " ", $show_images = true, $orderby = 'id',27 $show_description = true, $show_rating = false,28 $limit = -1, $show_updated = 0) {29 global $wpdb;30 $cat_id = -1;31 $results = $wpdb->get_results("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$cat_name'");32 if ($results) {33 foreach ($results as $result) {34 $cat_id = $result->cat_ID;35 }36 }37 get_links($cat_id, $before, $after, $between, $show_images, $orderby,38 $show_description, $show_rating, $limit, $show_updated);39 }40 41 /** function wp_get_linksbyname()42 ** Gets the links associated with the named category.43 ** Parameters:44 ** category (no default) - The category to use.45 **/46 function wp_get_linksbyname($category, $args = '') {47 global $wpdb;48 49 $cat_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category' LIMIT 1");50 51 if (! $cat_id)52 return;53 54 $args = add_query_arg('category', $cat_id, $args);55 wp_get_links($args);56 } // end wp_get_linksbyname57 2 58 3 /** function wp_get_links() … … 204 149 } 205 150 206 207 /** function get_linkobjectsbyname()208 ** Gets an array of link objects associated with category 'cat_name'.209 ** Parameters:210 ** cat_name (default 'noname') - The category name to use. If no211 ** match is found uses all212 ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',213 ** 'url', 'description', or 'rating'. Or maybe owner. If you start the214 ** name with an underscore the order will be reversed.215 ** You can also specify 'rand' as the order which will return links in a216 ** random order.217 ** limit (default -1) - Limit to X entries. If not specified, all entries218 ** are shown.219 **220 ** Use this like:221 ** $links = get_linkobjectsbyname('fred');222 ** foreach ($links as $link) {223 ** echo '<li>'.$link->link_name.'</li>';224 ** }225 **/226 // Deprecate in favor of get_linkz().227 function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) {228 global $wpdb;229 $cat_id = -1;230 //$results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");231 // TODO: Fix me.232 if ($results) {233 foreach ($results as $result) {234 $cat_id = $result->cat_id;235 }236 }237 return get_linkobjects($cat_id, $orderby, $limit);238 }239 240 /** function get_linkobjects()241 ** Gets an array of link objects associated with category n.242 ** Parameters:243 ** category (default -1) - The category to use. If no category supplied244 ** uses all245 ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',246 ** 'url', 'description', or 'rating'. Or maybe owner. If you start the247 ** name with an underscore the order will be reversed.248 ** You can also specify 'rand' as the order which will return links in a249 ** random order.250 ** limit (default -1) - Limit to X entries. If not specified, all entries251 ** are shown.252 **253 ** Use this like:254 ** $links = get_linkobjects(1);255 ** if ($links) {256 ** foreach ($links as $link) {257 ** echo '<li>'.$link->link_name.'<br />'.$link->link_description.'</li>';258 ** }259 ** }260 ** Fields are:261 ** link_id262 ** link_url263 ** link_name264 ** link_image265 ** link_target266 ** link_category267 ** link_description268 ** link_visible269 ** link_owner270 ** link_rating271 ** link_updated272 ** link_rel273 ** link_notes274 **/275 // Deprecate in favor of get_linkz().276 function get_linkobjects($category = -1, $orderby = 'name', $limit = -1) {277 global $wpdb;278 279 $sql = "SELECT * FROM $wpdb->links WHERE link_visible = 'Y'";280 if ($category != -1) {281 $sql .= " AND link_category = $category ";282 }283 if ($orderby == '')284 $orderby = 'id';285 if (substr($orderby,0,1) == '_') {286 $direction = ' DESC';287 $orderby = substr($orderby,1);288 }289 if (strcasecmp('rand',$orderby) == 0) {290 $orderby = 'rand()';291 } else {292 $orderby = " link_" . $orderby;293 }294 $sql .= ' ORDER BY ' . $orderby;295 $sql .= $direction;296 /* The next 2 lines implement LIMIT TO processing */297 if ($limit != -1)298 $sql .= " LIMIT $limit";299 300 $results = $wpdb->get_results($sql);301 if ($results) {302 foreach ($results as $result) {303 $result->link_url = $result->link_url;304 $result->link_name = $result->link_name;305 $result->link_description = $result->link_description;306 $result->link_notes = $result->link_notes;307 $newresults[] = $result;308 }309 }310 return $newresults;311 }312 313 151 function get_linkrating($link) { 314 152 return apply_filters('link_rating', $link->link_rating); 315 }316 317 318 /** function get_linksbyname_withrating()319 ** Gets the links associated with category 'cat_name' and display rating stars/chars.320 ** Parameters:321 ** cat_name (default 'noname') - The category name to use. If no322 ** match is found uses all323 ** before (default '') - the html to output before the link324 ** after (default '<br />') - the html to output after the link325 ** between (default ' ') - the html to output between the link/image326 ** and it's description. Not used if no image or show_images == true327 ** show_images (default true) - whether to show images (if defined).328 ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',329 ** 'url' or 'description'. Or maybe owner. If you start the330 ** name with an underscore the order will be reversed.331 ** You can also specify 'rand' as the order which will return links in a332 ** random order.333 ** show_description (default true) - whether to show the description if334 ** show_images=false/not defined335 ** limit (default -1) - Limit to X entries. If not specified, all entries336 ** are shown.337 ** show_updated (default 0) - whether to show last updated timestamp338 */339 function get_linksbyname_withrating($cat_name = "noname", $before = '',340 $after = '<br />', $between = " ",341 $show_images = true, $orderby = 'id',342 $show_description = true, $limit = -1, $show_updated = 0) {343 344 get_linksbyname($cat_name, $before, $after, $between, $show_images,345 $orderby, $show_description, true, $limit, $show_updated);346 }347 348 /** function get_links_withrating()349 ** Gets the links associated with category n and display rating stars/chars.350 ** Parameters:351 ** category (default -1) - The category to use. If no category supplied352 ** uses all353 ** before (default '') - the html to output before the link354 ** after (default '<br />') - the html to output after the link355 ** between (default ' ') - the html to output between the link/image356 ** and it's description. Not used if no image or show_images == true357 ** show_images (default true) - whether to show images (if defined).358 ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',359 ** 'url' or 'description'. Or maybe owner. If you start the360 ** name with an underscore the order will be reversed.361 ** You can also specify 'rand' as the order which will return links in a362 ** random order.363 ** show_description (default true) - whether to show the description if364 ** show_images=false/not defined .365 ** limit (default -1) - Limit to X entries. If not specified, all entries366 ** are shown.367 ** show_updated (default 0) - whether to show last updated timestamp368 */369 function get_links_withrating($category = -1, $before = '', $after = '<br />',370 $between = " ", $show_images = true,371 $orderby = 'id', $show_description = true,372 $limit = -1, $show_updated = 0) {373 374 get_links($category, $before, $after, $between, $show_images, $orderby,375 $show_description, true, $limit, $show_updated);376 153 } 377 154 … … 394 171 $cat = get_category($cat_id); 395 172 return $cat->cat_name; 396 }397 398 /** function get_get_autotoggle()399 ** Gets the auto_toggle setting of category n.400 ** Parameters: id (default 0) - The category to get. If no category supplied401 ** uses 0402 */403 function get_autotoggle($id = 0) {404 return 0;405 173 } 406 174
Note: See TracChangeset
for help on using the changeset viewer.