How to include PHP files in plugins the correct way

Coming in late to this party, but here’s the “WordPress” way: use plugin_dir_path( __FILE__ ), e.g.:

<?php
include( plugin_dir_path( __FILE__ ) . 'ipn/paypal-ipn.php');
?>

Note that the function does return the trailing slash for the filepath.

Leave a Comment