Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
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. –  Mark Kaplun Feb 25 '13 at 9:03
    
Best practices for plugin development . . . . –  brasofilo Feb 25 '13 at 9:12
    
@MarkKaplun This is exactly what I was trying to achive. Thanks for the tip. –  WordPress Developer Feb 25 '13 at 10:10

1 Answer 1

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.

share|improve this answer
    
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. –  WordPress Developer Feb 25 '13 at 10:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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