How to find php file or function that generates a

2019-09-02 01:49发布

I want to debug a certain submit action inside a plugin's admin panel. The panel stays inside the dashboard of wordpress. Its url is as follows:

http://localhost/wordpress/wp-admin/admin.php?page=pods&action=edit&id=681&do=create

The submit action is not specified. Thus it is handled by the same php file that generated the above page.

<form action="" method="post" class="pods-submittable">

How can I find out the php file that generated the above page?

2条回答
混吃等死
2楼-- · 2019-09-02 02:18

If you are talking about https://wordpress.org/extend/plugins/pods/ then go to your Wordpress plugins directory and look in the 'pods' folder. The following files contain that string:

/pods/ui/admin/setup-edit.php
/pods/ui/admin/setup-add.php
/pods/components/Roles/ui/add.php
/pods/components/Migrate-Packages/ui/wizard.php
/pods/components/Migrate-CPTUI/ui/wizard.php

Without knowing what action you are trying to perform I can't narrow down which file is the one being used for that action. If you can post the HTML for some additional form fields on that page I can do a search in these files for that HTML.

查看更多
smile是对你的礼貌
3楼-- · 2019-09-02 02:41

The following script let you find any wordpress plugin and, obviously, the page parameters is key for the search.

For example in the case page=pods, you must enter into your wordpress docroot and execute:

cd wp-content/plugins
find . -type f | xargs grep add_menu_page | grep pods

You should see the file(s) matching the search (it should be only one) and the row matched. The row matched is related to the function call add_menu_page. This function creates a new top level menu section in the admin menu.

If you take a look at WordPress Reference for add_menu_page function, the third parameter $menu_slug is the key to understand how the things works, this is the page parameter.

*The slug name to refer to this menu by (should be unique for this menu). Prior to Version 3.0 this was called the file (or handle) parameter. If the function parameter is omitted, the menu_slug should be the PHP file that handles the display of the menu page content*

查看更多
登录 后发表回答