网站优化

网站优化

Products

当前位置:首页 > 网站优化 >

如何在Wordpress插件之前定义常量

GG网络技术分享 2025-03-18 16:12 0


问题描述:

I have the plugin which have constant defined, i will call this plugin PLUGIN A:

if ( ! defined(\'BLA\')){

define(\'BLA\', \'http://google.com);

}

I want to make another plugin PLUGIN B which will define constant BLA before PLUGIN A. Is that possible? I guess Wordpress needs to read PLUGIN B before PLUGIN A, but in which order Wordpress is reading plugins?

图片转代码服务由CSDN问答提供

感谢您的意见,我们尽快改进~

功能建议

我有一个常量定义的插件,我将调用此插件PLUGIN A:</ p>

\\ n

  if(!defined(\'BLA\')){

define(\'BLA\',\'http://google.com);

}

</ code> </ pre>

我想制作另一个插件PLUGIN B,它将在PLUGIN A之前定义常量BLA。这可能吗? 我想Wordpress需要在PLUGIN A之前读取PLUGIN B,但Wordpress正在以哪种顺序读取插件?</ p>

</ div>

网友观点:

WordPress loads plugins in a specific order. I found this question/answer here on Stackoverflow: https://wordpress.stackexchange.com/questions/63141/in-what-order-does-wordpress-load-plugin-files

So, the order is:

  1. Must-use plugins (plugins in the optional mu-plugins folder)
  2. If you\'re running a multisite installation, it checks for plugins that are network-activated and loads those.
  3. Then it checks for all other active plugins by looking at the active_plugins entry of the wp_options database table, and loops through those. The plugins will be listed alphabetically.

Hope this helps!

标签:

提交需求或反馈

Demand feedback