Grab Static Method from Plugin

@kalenjohnson thanks for this PHP updates and your blog post. You are making me getting digger in to PHP new versions, which as you said, is very important.

I need to grab a static method from Contact Form 7 plugin to my extra.php file.

I think first I need to bring the class into the namespace but don’t know how. I tried adding use WPCF7_ContactForm; at the top of the file, but doesn’t seem to work.

I saw in another post @loganyott suggested use Site\Plugin\Document as doc; but don’t know how to apply it to this plugin.

Any help will be really appreciated!

Did you try referencing the class as \WPCF7_ContactForm?

Thanks for the answer @Foxaii, so you mean

$submission = WPCF7_Submission::get_instance();

should be

$submission = \WPCF7_ContactForm\WPCF7_Submission::get_instance();

??

Is that Contact Form 7 class actually namespaced?

No @kalenjohnson, I’m not namespacing actually. I’m not sure how to do this for this plugin.

The Contact Form 7 classes are in the global namespace, so just use \WPCF7_Submission::get_instance();

1 Like

Thank you very much @Foxaii and @kalenjohnson . Working now!

You rock! :smiley: