add_action in wp_head accessible from class

by Chris   Last Updated June 13, 2019 00:08 AM

Given this code:

class test_class {

    function greeting() {
        echo 'Howdy! Test is successful!';
    }

    function greeting_head() {
      //Close PHP tags
    ?>
        <?php greeting() ?>
    <?php //Open PHP tags
    }
}

add_action( 'wp_head', array( 'test_class', 'greeting_head' ) );

greeting() is undefined. How to access if from outside test_class?

Tags : php actions


Related Questions


Updated June 09, 2016 08:03 AM

Updated May 14, 2015 13:03 PM

Updated July 08, 2015 13:03 PM

Updated May 05, 2015 21:03 PM

Updated February 24, 2017 10:08 AM