How can plugins have their own pages?

Believe it or not the WordPress official documentation has a great page covering this topic called Administration Menus. It also provides example code on how to use WordPress hooks in your plugin code to add custom setting pages and other pages like that.

The page can be found here. Fire up the kettle and make yourself a coffee or tea before reading, because it is quite a large page. It even covers things like adding in forms and saving settings for your plugin that you can access.

** Update **

After further understanding what you were asking, it’s apparent you want to create a WordPress page from within your plugin, not an admin screen. Depending on whether or not you want to create it upon activation or when a user does a particular thing I’ll assume you want to create it upon activation and remove it upon deactivation.

I did not add in code for deleting pages, you should be able to work that part out though. The following should add in a page upon activation of your plugin.

    <?php

    register_activation_hook(__FILE__, 'activate_plugin');
    register_deactivation_hook(__FILE__, 'deactivate_plugin');
    register_uninstall_hook(__FILE__, 'uninstall_plugin');

    function activate_plugin() {

        // This function creates the pages
        create_pages();
    }

    function deactivate_plugin() {

        // This function removes the pages
        remove_pages();
    }

    function uninstall_plugin() {

        // This function removes the pages
        remove_pages();
    }

    function create_pages() {

        // Create post object
        $_p = array();
        $_p['post_title']     = "Some page title";
        $_p['post_content']   = "This is content in a page added via a plugin. This was not added manually, run!";
        $_p['post_status']    = 'publish';
        $_p['post_type']      = 'page';
        $_p['comment_status'] = 'closed';
        $_p['ping_status']    = 'closed';
        $_p['post_category'] = array(1); // the default 'Uncategorised'

        $page_id = wp_insert_post($_p);

        if ( $page_id ) {

            return true;

        }

    }

    function remove_pages() {

        // Code in here to remove pages you added

    }

?>

If you have any questions or issues using the sample code post up what you’re trying to accomplish and someone will sort you out. Good luck.