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

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

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.

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

Other (182)

Popular Keywords