Soft reject about including files

wordpress

#1

I receive such type of reject reason:

"Adding your own array with E_USER_ERROR may or may not always work, it depends on the server type and setup."
Also with screenshot from code. Here is the code:

[details=Code]foreach ( $includes as $file ) { $filepath = get_template_directory() . '/' . $file; if ( ! file_exists( $filepath ) ) : trigger_error( sprintf( esc_html__( 'Error locating %s for inclusion', 'domain_name' ), $file ), E_USER_ERROR ); endif; require_once $filepath; }[/details]

So, what is wrong?


#2

Use get_template_part - https://developer.wordpress.org/reference/functions/get_template_part/


#3

but it’s not template, it’s files with some functions :neutral_face:


#4

I see, so the reviewer is actually telling you not to use trigger_error becuse some servers can’t handle it properly

The support for this function is: PHP 4 >= 4.0.1, PHP 5, PHP 7)


#5

Sure, I saw requirements of using functions, but also in theme information we tell to clients minimal php version, I still don’t understand what’s a problem


#6

I have no idea what the reviewer is talking about, but why do you even need to throw an error when require_once will do the same if the file doesn’t exist? Seems like overkill to me.


#7

trigger_error was used for custom error handler, it’s was not necessary and now I removed it, but I still sure that it was not reason for reject. But they told me that E_USER_ERROR will not work in some “server type and setup”, is it right? What’s the “server type” it should be? without php? how WordPress will be installed and launched without php? I want to see it :slight_smile: