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.

When defining the callback that produces the HTML content for an admin settings page, I'd like to abstract the HTML into a separate file, but the HTML uses some wordpress functions, specifically current_user_can and screen_icon. These are claimed to be undefined when called through the included file but work fine inline.

function admin_menu_page_content() {

        if ( !current_user_can( 'manage_options' ) )  {
            wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
        }
        ?>
        <div class="wrap">  

            <?php include(plugins_url('plugin_name/forms/admin_form.php')) ?>
        </div> 
        <?php
    }
share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

Use plugin_dir_path() to include executable files. plugins_url() returns the web address, that’s not what you need.

<?php include(plugin_dir_path(__FILE__) . 'forms/admin_form.php') ?>
share|improve this answer
    
Ah, overlooked that. Thanks. –  Nicholas Pickering Dec 11 '12 at 22:48
add comment

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.