【发布时间】:2011-10-16 19:58:48
【问题描述】:
我有这样的定义:
define('LIBRARIES_URI', get_template_directory_uri() . '/libraries/');
现在,我有一个关联数组,例如:
array( 'name' => 'superfish-css', 'path' => LIBRARIES_URI .'superfish/css/superfish.css', 'type' => 'style' )
但是,路径不正确,这给了我一个错误,因为我猜有一个表达式。我尝试了各种东西,比如双引号之类的东西,但如果没有外部变量,我似乎无法正确处理。有没有办法正确插值?
完整示例:
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;
}
}
【问题讨论】:
-
您遇到的具体错误是什么?
-
这里没有看到任何错误...
-
嗯,您能更准确地说明您遇到的错误吗?如果我将
function get_remplate_directory_uri() {return '/var/www';}添加到顶部,这对我有用。 -
请粘贴
get_template_directory_uri... -
从问题推测,您正在尝试使用表达式声明类属性。那是不可能的。在构造函数中分配属性。
标签: php