Resources

My Agape try

Your Agape try


Support Forum

You must be logged in to post Login Register

Search 
Search Forums:


 




get_terms not returning any terms

UserPost

6:00 pm
April 14, 2009


danf

Member

posts 24

1

Im using get_terms with custom taxonomies and it no longer will return anything from the get_terms call. 


I don't have RS enabled on for these taxonomies as I manage access via categories, but I have a page that lists the terms for the custom taxonomies.

Have I configured incorrectly?  I would prefer to not turn on RS for these taxonomies as it just complicates it unnecesarily for me.


Thanks,

7:30 pm
April 14, 2009


danf

Member

posts 24

2

As I investigate more, it appears that when I specify a parent, and it calls _get_term_hierarchy, then the $parent value isn't set inside the hierarchy array and so returns an empty set.

So, it looks like its a filter inside the _get_term_hierarchy that is causing the issue.

7:47 pm
April 14, 2009


danf

Member

posts 24

3

I think I found it.  Inside your function: function rs_get_terms_children($taxonomy)

you do this: if ( ! $tx = $scoper->taxonomies->get($taxonomy) )
        return array();

This is my scenario where I don't have my taxonomies scoped, so it returns an array();  The problem is that inside the core: function _get_term_hierarchy($taxonomy) {

It does this:

$children = get_option("{$taxonomy}_children");
    if ( is_array($children) )
        return $children;

So, this is where you are overwriting the get_option call and returning an empty array, but now the check for is_array($children) is valid - it just returns 0 items in the array and returns that.  Your function should return false or something so that it continues past this and loads the {$taxonomy}_children from the database


9:29 pm
April 14, 2009


danf

Member

posts 24

4

I changed the return array(); to return '';  - and I now have my terms back :)

However, I believe that it is querying the database every time now to build the hierarchy since the call to get_options is being overwritten.

I believe the problem is now in role-scoper_main.php where it creates the filter:

add_filter("option_{$taxonomy}_children", create_function( '', "return rs_get_terms_children('$taxonomy');") );


Im not familiar enough with php and how it is creating the function on the fly, but is there a way the create_function can pass in the parameter that gets passed via the apply_filter ("option_{$taxonomy}_children", $data ) - that way I can return that variable instead of '' and it will save it from querying the database to build the hiearchy -

I have hundreds of terms within my custom taxonomy - so definitely want to cache that instead of building every time.


5:58 am
April 15, 2009


danf

Member

posts 24

5

I believe the following is working for me:

add_filter("option_{$taxonomy}_children", create_function( '$option_value', "return rs_get_terms_children('$taxonomy', $option_value);") );

Then change rs_get_terms_children to:

function rs_get_terms_children( $taxonomy, $option_value )

and places that previously returned array();, now return $option_value;


Kevin - would you let me know if this is something you can add to your code.


Thanks


11:26 am
April 20, 2009


Kevin

Admin

posts 2503

6

Dan, thanks for tracking this down. Your solution makes sense to me, and I have added it to the RS source with the following changes:

1) Make new option_value argument optional for compat with other calling code:

function rs_get_terms_children( $taxonomy, $option_value = " )

2) Change string construction for created function so '$option_value' is retained as part of the function text, and not evaluated to its value prior to function creation:

add_filter ( "option_{$taxonomy}_children", create_function( '$option_value', "return rs_get_terms_children('$taxonomy', " . '$option_value );') );

2:48 pm
May 31, 2011


fiblan

Member

posts 5

7

I think that i have same problem of this old topic then i not add new topic.

WP 3.1.3 && RS 1.3.39.

I get this issue with custom taxonomy when use WP get_terms (after filter 'get_terms'), tomorrow i'll investigate….

Have you any news about? Thanks


3:53 am
June 1, 2011


fiblan

Member

posts 5

8

I confirm the bug. I replicate it with a clean installation WP 3.1.3 (with only RS as plugin 1.3.39).

- add code to register custom taxonomy hierarchical functions.php (theme)

- create new term of taxonomy hierarchical

  • test 1.0.0
  •   test 1.1.0
  •     test 1.1.1

- activate rs plugin with clean configuration;

- when add new children term to custom taxonomy, the term is not show, is not returned from get_terms, but childrens "pre activation RS" are showed. If deactived RS plugin i get correct terms.


4:43 am
June 1, 2011


fiblan

Member

posts 5

9

workaround : deactivate & activate RS plugin. I think that the problem is in activation RS plugin (?)


6:12 am
June 1, 2011


Kevin

Admin

posts 2503

10

The updated Role Scoper development code (1.3.40-dev) has a fix for this issue.

4:58 am
July 20, 2011


fiblan

Member

posts 5

11

I have again same problem, workround: deactivate & activate RS plugin work.

RS: 1.3.42

WP: 3.2


1:45 am
July 21, 2011


fiblan

Member

posts 5

12

perfect… resolved with RS:1.3.43, thanks.


About the Agapetry forum

Currently Online:

15 Guests

Maximum Online: 150

Forums:

Groups: 2

Forums: 7

Topics: 1246

Posts: 5654

Members:

There are 1257 members

There are 1 guests


Kevin has made 2503 posts

Top Posters:

metal450 - 178

Ragnar - 108

YikYak - 70

whiteorb - 49

Daisy - 35

Administrator: Kevin | Moderators: Kevin