We use cookies to improve our services and provide a better experience. By continuing to use this site, you agree with our Cookies Policy.

Tutorials
More than 400 step-by-step articles to guide you through online project development.
HomeTutorialsCMS TutorialsWordPress

How to include a PHP file via a function that is part of a plugin

OpenVZ VPS
Germany Cloud Servers
KVM VPS
cPanel KVM
Ubuntu VPS
Linux Cloud Server
Linux KVM Hosting
Brazil VPS
USA VPS
Windows Cloud Server

Lets say we have PHP file and we would like to include it as a function in the plugin page. This might sound a bit hard to achieve, but it can be done easy and quickly. Simply use the following lines of code in the plugin file:

1
2
3
4
5
function Include_plugin() {
ob_start();
include(ABSPATH . "../plugin.php");
return ob_get_clean();
}

Basically that’s all we need to do in order to include PHP file in the plugin page. This way we are able to extend the functionality of specific plugin.

Linux Cloud Server
Windows Cloud Server
Brazil VPS
USA VPS
Germany Cloud Servers
Linux KVM Hosting
cPanel KVM
OpenVZ VPS
Ubuntu VPS
KVM VPS
Rate this Tutorial:
No Comments Leave a Comment
Leave a Comment

Other (182)

Popular Keywords