检查脚本/样式是否已入队/注册


Answers:



11

检查$GLOBALS['wp_scripts']->registered脚本。

function is_enqueued_script( $script )
{
    return isset( $GLOBALS['wp_scripts']->registered[ $script ] );
}

print (int) is_enqueued_script( 'l10n' );

$GLOBALS['wp_styles']->registered 以相同的方式工作。


1
投反对票是由于缺乏健全性检查,从而可能导致致命错误。
Backie 2011年

2
@Backie,但是您知道这是概念证明吗?
fuxia

wp_script_is()是一种更好,更安全的解决方案(Adam Backstrom`)解决方案
chrisjlee 2011年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.