• I have the plugin with folder/files and I am using the plugin in admin dashboard.
    Folder: views
    actions.php
    client_register.php

    And I created one menu like this

    add_submenu_page("custom", "Client Registration", "New Client Site",'manage_options', "client_register", 'page_client_register');
    
    if ( ! function_exists( 'page_client_register' ) ) {
        function page_client_register(){
            render_page_client_register();
        }
    }

    And I am able to call the page_client_registerfunction (which is actually a independent php file) like this.
    https://127.0.0.1/wp-admin/admin.php?page=client_register
    This is possible because I created the menu.

    How can I access other files similar to that way?
    using wp-admin/admin.php url

    If I directly call the files like https://127.0.0.1/wp-content/plugins/<pluginname>/views/actions.php it says Direct PHP ACCESS is not allowed in some cloud sites.

    How can I access these files using wp-admin/admin.php?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    You cannot, at least not that way. If you want to directly access your PHP files and they rely upon WP resources, you could route requests through /wp-admin/admin-post.php. Despite the name, it’ll work for GET requests too.

    For GET, include an action query string in the URL, whose value is used to compose an action hook handle that fires with the request. Add a callback function to that action hook. The callback can include or require other .php files. Review the file’s source code for better understanding on how this works. It’s relatively short and simple in what it does.

    Thread Starter skydev2020

    (@skydev2020)

    @bcworkz Thanks for your explanation, I have experience in using action query string in the URL but I have never thought it is related to hook.
    Thanks I will use action.
    Btw can you give me more info how to create route through /wp-admin/admin-post.php

    Moderator bcworkz

    (@bcworkz)

    More info can be found here: https://glennmessersmith.com/pages/wpenviro.html#useapost

    Use of admin-post.php isn’t very well documented in WP docs. The dynamic CSS bit in the linked document of course does not apply to your situation, but the action hook section could be applied to anything.

    Thread Starter skydev2020

    (@skydev2020)

    @bcworkz Thank you, it makes very clear now.
    Regards

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Access plugin php using wp-admin/admin.php url’ is closed to new replies.