Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter sprowt

    (@sprowt)

    Moderator bcworkz

    (@bcworkz)

    “join(): Invalid arguments passed” means either the first arg is not a string (it is a string in your case) or the second is not array of strings. The second is the return from wphierarchy_get_element_classes(). This is likely not returning what we expect. var_dump the return to confirm. If it’s not as expected, work back into the function, examining intermediate values to zero in on where things went bad. Basic debugging techniques.

    “Undefined variable: classes” means you tried to use $classes without first assigning a value to it. I don’t see any source code for index.php, so I cannot speculate further.

    Thread Starter sprowt

    (@sprowt)

    thanks for your time, BC.

    here’s my theme repo:
    https://github.com/LGitHub-sprout/wordpress/tree/main/wphierarchy/app/public/wp-content/themes/wphierarchy

    there’s not much in it except the functionality i’m having trouble with, so there’s not a lot of digging involved ??

    i get null on var_dump( $classes );

    /app/public/wp-content/themes/wphierarchy/index.php:26:null

    i’m assuming the invalid join args is because $classes is null, and therefore neither a string nor an array of strings.

    however, it is assigned in markup.php on line 30:

    if ( ! function_exists( 'wphierarchy_create_header_classes' ) ) {
      add_filter( 'wphierarchy_create_header_class',
                  'wphierarchy_create_header_classes' );
    /**
    * Adds custom classes to the header.
    */
    function wphierarchy_create_header_classes( $classes ) {
      $classes[] = 'site-header';
    }
      return $classes;
    }

    other than that there’s not much to work back to.

    what am i missing?? i’m stumped. unless this functionality is hooked into some other code in the the GP theme i’m not seeing/including.

    thanks so much for your help!

    Thread Starter sprowt

    (@sprowt)

    i should also mention that i do get class="" in the html elements i use function but the actual specific class isn’t output.

    • This reply was modified 4 years, 1 month ago by sprowt.
    Moderator bcworkz

    (@bcworkz)

    return $classes; is outside of the function declaration ?? The function thus never returns the value that it assigns.

    Thread Starter sprowt

    (@sprowt)

    that’s it, thank you!

    after seeing it done in GP theme, i also cleared the join() error by passing the $classes arg twice as tom does in his footer.php.

    a little digging paid off on that one.

    as always, BC… i SO APPRECIATE your help and am really having fun with wordpress and php, thanks to you.

    have a great weekend <3

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘getting join() error with undefined $classes variable’ is closed to new replies.