2

修正方法がわからない 2 種類のエラーが発生しています。

ここでエラーを確認できます: http://www.brainbuzzmedia.com/themes/vertex/

最初のタイプは 2 回発生し、次のようになります。

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');

2 番目のエラー タイプは次のとおりです。

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('mcolorpicker', $path . 'js/mColorPicker.js', array('jquery'));

wp_enqueue_style('chosen', $path .'css/chosen.css');

wp_enqueue_style('content-layout', $path .'css/content-layout.css');

wp_enqueue_script('jquery-json', $path . 'js/jquery.json.js', array('jquery'));

wp_enqueue_script('chosen-jquery', $path . 'js/chosen.jquery.min.js', array('jquery'));

wp_enqueue_script('content-layout-js', $path . 'js/content-layout.js', array('jquery', 'jquery-ui-sortable'));

フロントエンドのディスプレイにも必要になるのではないかと思います。これらを正しい方法でキューに入れるにはどうすればよいですか?

  • 更新 2

未定義のプロパティ エラーのうち 2 つが発生するコードを次に示します。

txtへのリンク

4

1 に答える 1

2

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');
}

参照: コーデックス

jQueryロードされていないため、2番目のエラーが発生しました。

アップデート:

あなたが何かを持っているか、あなたのまたはあなたのどれかwp_register_script(xxx)を直接wp_enqueue_style(xxx)呼び出す場合は、次のようにハンドラー内でそれらを使用してくださいfunctions.phpplugin filewp_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
}
于 2012-07-05T01:24:32.263 に答える