1
내 플러그인에 1 개의 CSS 및 2 개의 js 파일 (jquery.min.js 및 jquery.googleplus-activity-1.0.min.js)을 포함해야합니다.Wordpress에 jQuery 플러그인을 포함시키는 방법은 무엇입니까?
은 내가 JS 파일을 모두 추가 할
function my_init_method()
{
wp_deregister_script('jquery');
wp_enqueue_script('jquery', '' . get_bloginfo('wpurl') . '/wp-content/plugins/googe_plus/js/jquery.min.js');
}
function addHeaderCode() {
echo '<link type="text/css" rel="stylesheet" href="' . get_bloginfo('wpurl') . '/wp-content/plugins/googe_plus/css/style.css" />' . "\n";
}
function my_jsscripts_method() {
wp_deregister_script('jquery');
wp_register_script('jquery', '' . get_bloginfo('wpurl') . '/wp-content/plugins/googe_plus/js/jquery.googleplus-activity-1.0.min.js');
wp_enqueue_script('jquery');
}
add_action('init', 'my_init_method');
//Include CSS
add_action('wp_head', 'addHeaderCode');
//Include JS
add_action('wp_enqueue_scripts', 'my_jsscripts_method');
하지만 수이 코드를 사용하고 있습니다. 내가 jquery.min.js을 포함해야 명심 먼저 CSS와 다른 JS 파일 jquery.googleplus 활동-1.0.min.js
질문에 답변하지 않지만 다른 플러그인에서도 jQuery를 사용할 수 있습니다. JS를 추가하기 전에 jQuery가 존재하는지 확인하십시오. – Raptor
@ ShivanRaptor 예 알아요.하지만 전 세계적으로 사용하지 않을 수도 있습니다. 그래서 그것을 포함해야합니다. –