0

I have a plugin with the following structure:

myplugin.php
   includes/authentication.php

I can access core WordPress functionality inside myplugin.php fine, but when I try to access stuff such as add_action('init', 'myaction') inside authentication.php, I receive a PHP error.

I tried including the WordPress wp-load.php file in order to gain core functionality, but the WordPress repository doesn't accept plugins that load wp-config or wp-load files.

What is the best way to proceed in this situation and why don't I have access to core WordPress functions from a plugin that is loaded.

3
  • 1
    Please include the full scenario of what you are trying to achieve. Right now it sounds like you are trying to access the URL of includes/authentication.php which is a big NO NO. Commented Feb 25, 2013 at 9:03
  • Best practices for plugin development . . . .
    – brasofilo
    Commented Feb 25, 2013 at 9:12
  • @MarkKaplun This is exactly what I was trying to achive. Thanks for the tip.
    – Dzhuneyt
    Commented Feb 25, 2013 at 10:10

1 Answer 1

0

You should include your includes/authentication.php in your myplugin.php like that:

include('includes/authentication.php');

You can use all the WordPress-Functions there.

If there are any specific functions that don't work for you, please list them, and show us how you included your includes/authentication.php.

1
  • I decided to go down another path: Registering a custom admin page in myplugin.php and including the code that was inside authentication.php in the callback function (the one that displays the custom page). However, I've stumbled upon something.
    – Dzhuneyt
    Commented Feb 25, 2013 at 10:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.