我得到两种类型的错误,我不知道如何修复。
您可以在这里看到错误:http://www.brainbuzzmedia.com/themes/vertex/
第一种类型出现两次,如下所示:
Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.) in /home/admin/buzz/themes/vertex/wp-includes/functions.php on line 3587我在functions.php有个电话:
function my_init() {
if (!is_admin()) {
wp_enqueue_script('jquery');
}
}
add_action('init', 'my_init');第二种错误类型是:
Notice: Undefined property: stdClass::$slider_height in /vertex/wp-content/themes/vertex/slider_settings.php on line 32无论在哪里( if语句的内部或外部,或者两者都定义),我都定义了这些变量,它们仍然给了我这个错误。
*最新情况
我有一些其他脚本在主题文件的子文件夹中排队,主要用于管理区域。
$path = get_template_directory_uri()。'/includes/metabox/smart_meta_box/smart_meta_fields/layout-editor/';
Wp_enqueue_script(“色选器”,$path .)‘’js/m科罗拉多Picker.js‘,数组(’jquery‘);
Wp_enqueue_style(“”,$path .‘'css/chosen.css');
Wp_enqueue_style(“内容-布局”,$path .‘'css/content-layout.css');
Wp_enqueue_script(‘jquery’,$path .‘'js/jquery.json.js’数组(‘jquery’);
Wp_enqueue_script(‘jquery jquery’),$path。‘'js/chosen.jquery.min.js',数组(’jquery‘);
Wp_enqueue_script(‘内容-布局-js’,$path .‘'js/content-layout.js',数组(’jquery‘,’jquery sortable‘);
我认为他们也可能需要前端显示以及。我怎样才能以正确的方式排队呢?
下面是发生两个未定义属性错误的代码:
链接到txt
发布于 2012-07-05 01:24:32
使用wp_enqueue_scripts操作来调用这个函数,或者使用admin_enqueue_scripts在管理端调用它。
要将其加载到前端,请使用
add_action('wp_enqueue_scripts', 'my_scripts_method');
function my_scripts_method() {
wp_enqueue_script('jquery');
}若要为管理员加载它,请使用
add_action('admin_enqueue_scripts', 'my_admin_scripts_method');
function my_admin_scripts_method() {
wp_enqueue_script('jquery');
}参考文献: Codex.
第二个错误发生是因为没有加载jQuery。
更新:
如果wp_register_script(xxx)或wp_enqueue_style(xxx)调用直接存在于functions.php或any plugin file中,则在wp_enqueue_script处理程序中使用它们,如下所示
add_action('wp_enqueue_scripts', 'my_scripts_method');
function my_scripts_method() {
wp_register_script('xxx'); // replace the xxx with valid script name
wp_enqueue_script('jquery');
wp_enqueue_style(xxx) // if you have any
}https://stackoverflow.com/questions/11336578
复制相似问题