• Resolved alx359

    (@alx359)


    I’ve an issue that after disabling everything have pinpointed to TG. Namely, I can’t set a parent category for a child, for taxonomies where TG is enabled (e.g. product_cat).

    Example:

    Category1: test1
    Category2: test2
    Parent category for test2: test1 <== can’t save that.

    As a workaround, disabling support for the given taxonomy in ‘Tag Groups Settings’ fixes the issue.

    I’ve define('WP_DEBUG', true); all the time in my dev laptop (WAMP32/Win7x64). The entry I get after trying to save the parent change is:

    PHP Notice: Trying to get property of non-object in D:\domains\my.domain.com\wp-content\plugins\tag-groups\tag-groups.php on line 620

    which reads like this:

    
    619:    $screen = get_current_screen();
    620:    $taxonomy = $screen->taxonomy;
    

    Please advise.

    Thanks.

Viewing 12 replies - 1 through 12 (of 12 total)
  • Yes, this is a bug that is already scheduled for repair in the next version.

    Could you please try to edit the code? Replace the entire function tg_add_taxonomy_columns with that piece: https://pastebin.com/0vi9VZt0

    Thread Starter alx359

    (@alx359)

    Hi Chris,
    Thanks for the so quick response with a tentative solution. Unfortunately, it didn’t fix the issue for me. No PHP notice anymore though.

    Actually, even stripping the whole block with the fix doesn’t help updating the parent either:

    
    function tg_add_taxonomy_columns( $columns )
    {
        return $columns;
    }
    

    Thanks.

    The problem seems to be somewhere else. I will investigate when I have more time. Maybe you can for the time being set the parents for the categories while this taxonomy is disabled in the plugin, and then enable it again.

    • This reply was modified 6 years, 7 months ago by Christoph.
    Thread Starter alx359

    (@alx359)

    Yes, of course. This is how I finally managed to do the task at hand.

    Thanks again, and hope you can fix this. TG fits a crucial piece in our project: a simple and elegant association of 2 very different taxonomies (product_tag, attachment_category — via Media Library Assistant). TG has enabled matching terms of the latter into the former with 10 lines of custom code. Even after much delving and experimenting I’m not yet aware of other straightforward enough way of doing this.

    Thread Starter alx359

    (@alx359)

    Did some quick debug and the culprit seems to be in tg_update_edit_term_group around li 686 here:

    
        $screen = get_current_screen();
    
        if ( !isset( $_POST['term-group'] ) && !isset( $_POST['term-group-option'] ) ) {
            return;
        }
    

    After changing it to || it seems to start working:

    
        $screen = get_current_screen();
    
        if ( !isset( $_POST['term-group'] ) || !isset( $_POST['term-group-option'] ) ) {
            return;
        }
    

    Perhaps it’s some of the next checks, like this one:

        if ( is_object( $screen ) && (!in_array( $screen->taxonomy, $tag_group_taxonomy ) ) && (!isset( $_POST['new-tag-created'] )) ) {
            return;
        }
    

    Anyway, what seems plausible IMHO is the term form cannot proceed submitting because a global TG check is holding the whole thing back.

    HTH.

    Thanks for pointing me to that place.

    The problem could simply be a result of $_POST[‘parent’] not being saved as $term[‘parent’]. But that’s just a guess, I need to try it.

    See https://codex.wordpress.org/Function_Reference/wp_update_term

    So you could try something like:

    
     if ( isset( $_POST['parent'] ) && ($_POST['parent'] != '') ) {
                $term['parent'] = (int) $_POST['parent'] ;
            }
    
    Thread Starter alx359

    (@alx359)

    Sorry, I’m not following. Trying it where exactly?

    Add it inside the function tg_update_edit_term_group, around line 740, before
    if ( isset( $_POST['tag-groups-taxonomy'] ) ) {.

    Thread Starter alx359

    (@alx359)

    Yep, it’s working now. Thank you!

    Ah, my bad, simply forgot to add that parameter! Thank you for testing!

    And you changed || back to &&? https://wordpress.org/support/topic/cant-set-parent-category-issue/#post-9467649

    Thread Starter alx359

    (@alx359)

    Yes, of course. Thanks!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Can’t set parent category issue’ is closed to new replies.