Create a function that can be used anywhere within WordPress site

I want to create a number of functions in my plugin ‘membershipintegration.php’ which can be called anywhere on my WordPress site.

I thought that if I created a class and defined a public function within the class in the membershipintegration.php I could use it wherever I liked.

class MembershipIntegration
{
  public function switchmembership () {
  echo 'some code'
  }
}

However, it doesn’t seem to work and I’ve used ‘function_exists’ on my sandbox page and it says the function isn’t active.

Any thoughts much appreciated. Thank you.

Read more here: Create a function that can be used anywhere within WordPress site

Leave a Reply

Your email address will not be published. Required fields are marked *