Wordpress自定义插件发布拒绝了“直接调用核心加载文件”的原因

I have developed a plugin for myself and was using it for a little and after decided to go public. But the plugin got declined after submission and code review with the reason ##Calling core loading files directly. I fixed already all issues they mentioned, but only one bothering me now. I have require_once( ABSPATH.'/wp-admin/includes/upgrade.php' ); in few places to use dbDelta(), but if I will remove require_once declaration I won't be able to use dbDelta(). Do you think it will be an issue with second code review? Any developer who already did and released their plugins?

Short and simple:

It shouldn't be an issue.

Longer Answer: dbDelta() is a function that's kind of a special case, because the "core file" (upgrade.php) that defines it isn't always going to be loaded when it's needed by your plugin.

If it's a simple query, you could probably just use a prepared statement with $wpdb. However if dbDelta() is indeed better for your needs (and it sounds like it is), it's absolutely okay to use require_once with upgrade.php, despite it technically being a core file.

Take a look at the official Creating Tables with Plugins codex page that literally tells you to go ahead and use it in this manner:

require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql );

With the reasoning:

[...] we'll use the dbDelta function in wp-admin/includes/upgrade.php (we'll have to load this file, as it is not loaded by default) [...]

So, require_once away my friend!

Alrighty, great news!

Plugin got approved and it's already public :)

Thank you, everyone, for the recommendations!

You can release your plugin php code with require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );