Opened 15 months ago

Closed 15 months ago

Last modified 15 months ago

#20129 closed defect (bug) (invalid)

get_bookmark object should return array of categories

Reported by: andrewheins Owned by:
Priority: normal Milestone:
Component: Taxonomy Version: 3.3.1
Severity: minor Keywords:
Cc:

Description

get_bookmark() returns a bookmark object with a single taxonomy and term_id, which are returned as strings.

In the WordPress admin section, it's possible to select multiple categories for a link (or bookmark, as it were).

get_bookmark() currently pulls all bookmarks for the categories you choose, and then runs array_unique on them to weed out duplicates. You only wind up with whatever the first category it pulled from.

It would be more consistent to merge those duplicate links, creating an array of term_ids for that bookmark, and allowing the developer to pull all of the terms for that bookmark.

Change History (3)

  • Keywords reporter-feedback added

Can you post a code example showing actual vs expected output? From what I can see, the function already returns an array of category IDs, which seems to be what you want:

array (
  'link_id' => 1,
  'link_url' => 'http://codex.wordpress.org/',
  'link_name' => 'Documentation',
  'link_image' => '',
  'link_target' => '',
  'link_description' => '',
  'link_visible' => 'Y',
  'link_owner' => '1',
  'link_rating' => 0,
  'link_updated' => '0000-00-00 00:00:00',
  'link_rel' => '',
  'link_notes' => '',
  'link_rss' => '',
  'link_category' => 
  array (
    0 => 2,
    1 => 12,
    2 => 15
  ),
)
  • Resolution set to invalid
  • Status changed from new to closed

Ah, I see now. That's what happens if you pull it with an ID. I

stdClass::__set_state(
  array( 
    'link_id' => 10, 
    'link_url' => 'https://github.com/andrewheins', 
    'link_name' => 'Github', 
    'link_image' => '', 
    'link_target' => '_blank', 
    'link_description' => '', 
    'link_visible' => 'Y', 
    'link_owner' => '1', 
    'link_rating' => 0, 
    'link_updated' => '0000-00-00 00:00:00', 
    'link_rel' => '', 
    'link_notes' => '', 
    'link_rss' => '', 
    'object_id' => '10', 
    'term_taxonomy_id' => '10', 
    'term_order' => '0', 
    'term_id' => '10', 
    'taxonomy' => 'link_category', 
    'description' => '', 
    'parent' => '0', 
    'count' => '3', 
  )
)
Version 0, edited 15 months ago by andrewheins (next)
  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.