我有这样的定义:
define('LIBRARIES_URI', get_template_directory_uri() . '/libraries/');现在,我有一个像这样的关联数组:
array( 'name' => 'superfish-css', 'path' => LIBRARIES_URI .'superfish/css/superfish.css', 'type' => 'style' )然而,path是不正确的,这给了我一个错误,因为我猜有一个表达式。我尝试了各种方法,比如双引号和其他东西,但如果没有外部变量,我似乎无法正确完成。有没有一种方法可以正确地对其进行插值?
完整示例:
define('LIBRARIES_PATH', TEMPLATEPATH . '/libraries/');
class Kosmos
{
private static $inclusions = array(
array( 'name' => 'style.css', 'path' => "get_bloginfo('stylesheet_url')", 'type' => 'style' ),
array( 'name' => 'jquery', 'path' => '', 'type' => 'script' ),
array( 'name' => 'jquery-ui-core', 'path' => '', 'type' => 'script' ),
array( 'name' => 'jquery-ui-tabs', 'path' => '', 'type' => 'script' ),
array( 'name' => 'superfish-css', 'path' => LIBRARIES_URI .'superfish/css/superfish.css', 'type' => 'style' ),
array( 'name' => 'superfish-js', 'path' => "LIBRARIES_URI . 'superfish/js/superfish.js'", 'type' => 'script', 'dep' => array('jquery') ),
array( 'name' => 'superfish-hover', 'path' => "LIBRARIES_URI . 'superfish/js/hoverIntent.js'", 'type' => 'script', 'dep' => array('jquery') ),
array( 'name' => 'jquery-color', 'path' => "LIBRARIES_URI . 'horizontalMenu/jquery.color-RGBa-patch.js'", 'type' => 'script' ),
/* admin */
array( 'name' => 'admin-css', 'path' => "ADMIN_CSS_URI . 'admin.css'", 'type' => 'admin-style' ),
array( 'name' => 'tabs-js', 'path' => "LIBRARIES_URI . 'tabs/tabs.js'", 'type' => 'admin-script' )
);
private static $admin_inclusions = array();
public function inclusions() {
return self::$inclusions;
}
public function admin_inclusions() {
return self::$admin_inclusions;
}
}发布于 2011-10-17 04:38:00
类属性声明可以不包含表达式,只能包含文字/常量值。
将赋值移动到构造函数中。
https://stackoverflow.com/questions/7786902
复制相似问题