admin管理员组文章数量:1390513
Some commercial themes have become a real mess: the header may be created by the files in the theme folder or by child theme or maybe from a legacy folder which is located inside a legacy plugin.
In those case how can I find which is the real piece of code which is executed?
Some commercial themes have become a real mess: the header may be created by the files in the theme folder or by child theme or maybe from a legacy folder which is located inside a legacy plugin.
In those case how can I find which is the real piece of code which is executed?
Share Improve this question asked Mar 23, 2020 at 20:02 ReviousRevious 3233 silver badges16 bronze badges1 Answer
Reset to default 1Due to said complexity, it's a pretty generic question without a specific answer. But here are some ideas based on what I do to grok through other people's code.
Forward/Back-tracing
I do a lot of forward tracing and back tracing through code. If you have an IDE (or something like Notepad++), you can do a "search all" through the entire directory to find "clues" as to what you're looking for.
For example, if you're trying to find where something comes from, start by looking at specific output you can target in a search - some text or HTML that you can key off of. Once you find where it's generated, you can back trace through the functions that are generated and look for various includes.
Breakpoints and debug code
Sometimes, if you're really not sure, it may be necessary to create a breakpoint or some debugging output to see if you're even in the right place, execution-wise.
If I'm not sure I'm even in the right place, I might drop in something like this:
echo 'You are here'; exit();
If it's a production site, that may not be appropriate, but you can do related things like:
echo '<!-- you are here... -->';
That gives you an HTML comment in the generated output.
Or, use the log file:
error_log( 'this point was hit.' );
If you're logging, make sure you have debugging and debug logging turned on in your wp-config.php
file:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
PHP
PHP has a function get_included_files()
that will display all included files. Depending on how things are constructed in your theme, this may or may not work, but it might help so I'm including it as a possible suggestion:
$included_files = get_included_files();
foreach ($included_files as $filename) {
echo "$filename\n";
}
As I said in the beginning, this isn't a specific "do this and it is guaranteed to solve your problem" kind of answer. Just some suggestions and ideas that may help you get to what you need. Hope it helps.
本文标签: child themeGetting a list of the PHP files included to generate a page
版权声明:本文标题:child theme - Getting a list of the PHP files included to generate a page 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744642498a2617205.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论