WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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')) ?>
share|improve this question
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

Your Answer


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.