Skip to main content
added 212 characters in body
Source Link
Scott B
  • 5.7k
  • 14
  • 94
  • 148

I've isolated the source of a fatal error that's been occurring when a brand new site is previewed just after installing and activating the plugin I'm working on.

The problem appears to be that the "category_children" item in the options table is not being created.

Interestingly, it appears that two actions trigger WP to create the category_children option. They are: (1) Activating a theme that contains code to create categories and (2) Simply accessing the category manager.

If I do either of those, after activating the plugin, the category_children option is being created (presumably due to checks in the theme activation or the edit-tags.php load) and the error goes away.

Here's the code I'm using in my plugin to create the categories (executes on plugin activation only):

        if(!get_cat_ID('nofollow')){wp_create_category('nofollow',1);}
        if(!get_cat_ID('noindex')){wp_create_category('noindex',1);}

What am I missing? Do I need to explicitly call a method to have WordPress generate the category_children options array for these items?

UPDATE: Thanks to scribu's help below on the reason for this bug, I've found that the PARTIAL fix for this bug is to place this line just after my wp_create_category() calls are complete:

clean_term_cache('','category'); 

However, this does not work when called in the same plugin that creates the categories. I had to place it in a standalone plugin that's activated separately from the plugin that creates my categories.

I've isolated the source of a fatal error that's been occurring when a brand new site is previewed just after installing and activating the plugin I'm working on.

The problem appears to be that the "category_children" item in the options table is not being created.

Interestingly, it appears that two actions trigger WP to create the category_children option. They are: (1) Activating a theme that contains code to create categories and (2) Simply accessing the category manager.

If I do either of those, after activating the plugin, the category_children option is being created (presumably due to checks in the theme activation or the edit-tags.php load) and the error goes away.

Here's the code I'm using in my plugin to create the categories (executes on plugin activation only):

        if(!get_cat_ID('nofollow')){wp_create_category('nofollow',1);}
        if(!get_cat_ID('noindex')){wp_create_category('noindex',1);}

What am I missing? Do I need to explicitly call a method to have WordPress generate the category_children options array for these items?

UPDATE: Thanks to scribu's help below on the reason for this bug, I've found that the fix for this bug is to place this line just after my wp_create_category() calls are complete:

clean_term_cache('','category'); 

I've isolated the source of a fatal error that's been occurring when a brand new site is previewed just after installing and activating the plugin I'm working on.

The problem appears to be that the "category_children" item in the options table is not being created.

Interestingly, it appears that two actions trigger WP to create the category_children option. They are: (1) Activating a theme that contains code to create categories and (2) Simply accessing the category manager.

If I do either of those, after activating the plugin, the category_children option is being created (presumably due to checks in the theme activation or the edit-tags.php load) and the error goes away.

Here's the code I'm using in my plugin to create the categories (executes on plugin activation only):

        if(!get_cat_ID('nofollow')){wp_create_category('nofollow',1);}
        if(!get_cat_ID('noindex')){wp_create_category('noindex',1);}

What am I missing? Do I need to explicitly call a method to have WordPress generate the category_children options array for these items?

UPDATE: Thanks to scribu's help below on the reason for this bug, I've found that the PARTIAL fix for this bug is to place this line just after my wp_create_category() calls are complete:

clean_term_cache('','category'); 

However, this does not work when called in the same plugin that creates the categories. I had to place it in a standalone plugin that's activated separately from the plugin that creates my categories.

deleted 208 characters in body
Source Link
Scott B
  • 5.7k
  • 14
  • 94
  • 148

I've isolated the source of a fatal error that's been occurring when a brand new site is previewed just after installing and activating the plugin I'm working on.

The problem appears to be that the "category_children" item in the options table is not being created.

Interestingly, it appears that two actions trigger WP to create the category_children option. They are: (1) Activating a theme that contains code to create categories and (2) Simply accessing the category manager.

If I do either of those, after activating the plugin, the category_children option is being created (presumably due to checks in the theme activation or the edit-tags.php load) and the error goes away.

Here's the code I'm using in my plugin to create the categories (executes on plugin activation only):

        if(!get_cat_ID('nofollow')){wp_create_category('nofollow',1);}
        if(!get_cat_ID('noindex')){wp_create_category('noindex',1);}

What am I missing? Do I need to explicitly call a method to have WordPress generate the category_children options array for these items?

UPDATE: Thanks to scribu's help below on the reason for this bug, the partial solution I've found itthat the fix for this bug is to place this line just after my wp_create_category() calls are complete:

update_optionclean_term_cache('category_children''', array()'category'); 

However, this is only a partial solution, since it does not properly reset the category_children array accurately. I still need to figure out how to reset this array to reflect the proper settings.

I've isolated the source of a fatal error that's been occurring when a brand new site is previewed just after installing and activating the plugin I'm working on.

The problem appears to be that the "category_children" item in the options table is not being created.

Interestingly, it appears that two actions trigger WP to create the category_children option. They are: (1) Activating a theme that contains code to create categories and (2) Simply accessing the category manager.

If I do either of those, after activating the plugin, the category_children option is being created (presumably due to checks in the theme activation or the edit-tags.php load) and the error goes away.

Here's the code I'm using in my plugin to create the categories (executes on plugin activation only):

        if(!get_cat_ID('nofollow')){wp_create_category('nofollow',1);}
        if(!get_cat_ID('noindex')){wp_create_category('noindex',1);}

What am I missing? Do I need to explicitly call a method to have WordPress generate the category_children options array for these items?

UPDATE: Thanks to scribu's help below on the reason for this bug, the partial solution I've found it to place this line just after my wp_create_category() calls are complete:

update_option('category_children', array());

However, this is only a partial solution, since it does not properly reset the category_children array accurately. I still need to figure out how to reset this array to reflect the proper settings.

I've isolated the source of a fatal error that's been occurring when a brand new site is previewed just after installing and activating the plugin I'm working on.

The problem appears to be that the "category_children" item in the options table is not being created.

Interestingly, it appears that two actions trigger WP to create the category_children option. They are: (1) Activating a theme that contains code to create categories and (2) Simply accessing the category manager.

If I do either of those, after activating the plugin, the category_children option is being created (presumably due to checks in the theme activation or the edit-tags.php load) and the error goes away.

Here's the code I'm using in my plugin to create the categories (executes on plugin activation only):

        if(!get_cat_ID('nofollow')){wp_create_category('nofollow',1);}
        if(!get_cat_ID('noindex')){wp_create_category('noindex',1);}

What am I missing? Do I need to explicitly call a method to have WordPress generate the category_children options array for these items?

UPDATE: Thanks to scribu's help below on the reason for this bug, I've found that the fix for this bug is to place this line just after my wp_create_category() calls are complete:

clean_term_cache('','category'); 
added 213 characters in body
Source Link
Scott B
  • 5.7k
  • 14
  • 94
  • 148

I've isolated the source of a fatal error that's been occurring when a brand new site is previewed just after installing and activating the plugin I'm working on.

The problem appears to be that the "category_children" item in the options table is not being created.

Interestingly, it appears that two actions trigger WP to create the category_children option. They are: (1) Activating a theme that contains code to create categories and (2) Simply accessing the category manager.

If I do either of those, after activating the plugin, the category_children option is being created (presumably due to checks in the theme activation or the edit-tags.php load) and the error goes away.

Here's the code I'm using in my plugin to create the categories (executes on plugin activation only):

        if(!get_cat_ID('nofollow')){wp_create_category('nofollow',1);}
        if(!get_cat_ID('noindex')){wp_create_category('noindex',1);}

What am I missing? Do I need to explicitly call a method to have WordPress generate the category_children options array for these items?

UPDATE: Thanks to scribu's help below on the reason for this bug, the partial solution I've found it to place this line just after my wp_create_category() calls are complete:

update_option('category_children', array());

However, this is only a partial solution, since it does not properly reset the category_children array accurately. I still need to figure out how to reset this array to reflect the proper settings.

I've isolated the source of a fatal error that's been occurring when a brand new site is previewed just after installing and activating the plugin I'm working on.

The problem appears to be that the "category_children" item in the options table is not being created.

Interestingly, it appears that two actions trigger WP to create the category_children option. They are: (1) Activating a theme that contains code to create categories and (2) Simply accessing the category manager.

If I do either of those, after activating the plugin, the category_children option is being created (presumably due to checks in the theme activation or the edit-tags.php load) and the error goes away.

Here's the code I'm using in my plugin to create the categories (executes on plugin activation only):

        if(!get_cat_ID('nofollow')){wp_create_category('nofollow',1);}
        if(!get_cat_ID('noindex')){wp_create_category('noindex',1);}

What am I missing? Do I need to explicitly call a method to have WordPress generate the category_children options array for these items?

UPDATE: Thanks to scribu's help below on the reason for this bug, the solution I've found it to place this line just after my wp_create_category() calls are complete:

update_option('category_children', array());

I've isolated the source of a fatal error that's been occurring when a brand new site is previewed just after installing and activating the plugin I'm working on.

The problem appears to be that the "category_children" item in the options table is not being created.

Interestingly, it appears that two actions trigger WP to create the category_children option. They are: (1) Activating a theme that contains code to create categories and (2) Simply accessing the category manager.

If I do either of those, after activating the plugin, the category_children option is being created (presumably due to checks in the theme activation or the edit-tags.php load) and the error goes away.

Here's the code I'm using in my plugin to create the categories (executes on plugin activation only):

        if(!get_cat_ID('nofollow')){wp_create_category('nofollow',1);}
        if(!get_cat_ID('noindex')){wp_create_category('noindex',1);}

What am I missing? Do I need to explicitly call a method to have WordPress generate the category_children options array for these items?

UPDATE: Thanks to scribu's help below on the reason for this bug, the partial solution I've found it to place this line just after my wp_create_category() calls are complete:

update_option('category_children', array());

However, this is only a partial solution, since it does not properly reset the category_children array accurately. I still need to figure out how to reset this array to reflect the proper settings.

added 221 characters in body
Source Link
Scott B
  • 5.7k
  • 14
  • 94
  • 148
Loading
added 47 characters in body
Source Link
Scott B
  • 5.7k
  • 14
  • 94
  • 148
Loading
added 16 characters in body
Source Link
Scott B
  • 5.7k
  • 14
  • 94
  • 148
Loading
Source Link
Scott B
  • 5.7k
  • 14
  • 94
  • 148
Loading