creating a wordpress plugin- what globals and include files do it need

admin

Administrator
Staff member
I am creating my first wordpress plugin.
one of the questions i have is understanding what files i should be included in php files that are not directly called by wordpress.

For example:
I have the user submitting a form. In the form on a page i use the constant WP_PLUGIN_URL, which works fine. The form posts to

Code:
<form action="<?=WP_PLUGIN_URL?>/myplugin/lib/functions.php" method="post">

The constant works fine.
In functions.php I have and it does not recognize WP_PLUGIN_DIR. i get the message

<blockquote>
Use of undefined constant WP_PLUGIN_DIR
</blockquote>

So what is the proper way to included whats needed. Do i just include wp-includes/default-constants.php or is there a better way to do it?

Thanks

Code:
&lt;?php
global $current_user;
global $wpdb;

if ( isset($_POST['action']) ){
    switch($_POST['action']){
        case 'newpost':
            include_once(WP_PLUGIN_DIR.'/myplugin/lib/insert.php');
            insertDB();
            break;
    }
}

?>