• Resolved benjaminniess

    (@benjaminniess)


    Hi,

    Thanks for your plugin.

    There’s a minor problem when you register a taxonomy with several ojbect types assigned as an array instead of a string. If you look at the register_taxonomy function, the second parameter can be an array https://codex.www.ads-software.com/Function_Reference/register_taxonomy

    The problem is: in lh-user-taxonomies.php L56, the $object var has to be a string otherwise you stop the rest of the function. Could you add an extra condition if $object is an array and check with the in_array test ?

    Let me know if you need some help.
    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author shawfactor

    (@shawfactor)

    Ben,
    I am happy to make the change but, do you want to become a co-contributor, so you can make changes directly?

    Pete

    Thread Starter benjaminniess

    (@benjaminniess)

    Hi Pete,

    I’d prefer if you do it because it’s already hard for me to maintain my own plugins.

    Thanks mate!
    Ben

    Plugin Author shawfactor

    (@shawfactor)

    Ben,

    Have a look at this code, I’ve retooled the function so that it should now work for both arrays and strings, seems to work for me but can you please run your eyey over it?

    /**
    * This is our way into manipulating registered taxonomies
    * It’s fired at the end of the register_taxonomy function
    *
    * @param String $taxonomy	– The name of the taxonomy being registered
    * @param String $object	– The object type the taxonomy is for; We only care if this is “user”
    * @param Array $args	– The user supplied + default arguments for registering the taxonomy
    */
    public function registered_taxonomy($taxonomy, $object, $args) {
    global $wp_taxonomies;
    
    // Only modify user taxonomies, everything else can stay as is
    if ((is_string($object) and ($object == ‘user’)) or (is_array($object) and in_array(“user”, $object)) ){
    
    // We’re given an array, but expected to work with an object later on
    $args	= (object) $args;
    
    // Register any hooks/filters that rely on knowing the taxonomy now
    add_filter(“manage_edit-{$taxonomy}_columns”,	array($this, ‘set_user_column’));
    add_action(“manage_{$taxonomy}_custom_column”,	array($this, ‘set_user_column_values’), 10, 3);
    
    // Set the callback to update the count if not already set
    if(empty($args->update_count_callback)) {
    $args->update_count_callback	= array($this, ‘update_count’);
    }
    
    // We’re finished, make sure we save out changes
    $wp_taxonomies[$taxonomy]	= $args;
    self::$taxonomies[$taxonomy]	= $args;
    }
    }

    [Moderator note: code fixed. Please wrap code in the backtick character or use the code button. Thanks.]

    What do you think?

    pete

    • This reply was modified 7 years, 11 months ago by bdbrown.
    Plugin Author shawfactor

    (@shawfactor)

    Have you had a chance to look at this?

    Thread Starter benjaminniess

    (@benjaminniess)

    Hi mate,

    Yes it seems much better. I had a fatal error with the manage_edit-{$taxonomy}_columns probably due to my version of php (5.6) so I changed it with dots.

    I also changed a bit the structure si it’s WP coding standards friendly ??

    https://pastebin.com/jfj1RmAk

    Thanks again
    Ben

    Plugin Author shawfactor

    (@shawfactor)

    Thankyou this has been updated, I appreciate your help

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Taxonomy with multiple object types’ is closed to new replies.