2016-10-27 4 views
0

마스터 사이트 URL에서 일부 CSS/javascript를로드하는 것으로 보이는 테마가 있습니다. 이로 인해 몇 가지 문제가 발생합니다.

예를 들어 두 개의 Jquery가 사이트 URL에 잘로드되지만 부트 스트랩은 URL에서 가져 오기를 시도 할 때로드되지 않으므로 액세스 할 수 없습니다.

<script type='text/javascript' src='http://live-site.co.uk/wp-includes/js/jquery/jquery.js?ver=1.12.3'></script> 
<script type='text/javascript' src='http://live-site.co.uk/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.0'></script> 
<script type='text/javascript' src='//internal-site.co.uk/live/wp-content/themes/live-site-1/bootstrap.min.js?ver=1.0.159'></script> 
<script type='text/javascript' src='//internal-site.co.uk/live/wp-content/themes/live-site-1/script.js?ver=1.0.159'></script> 

필자는 이러한이 wp_register_script 및 wp_enque_script를 사용하여 호출되는 함수에 템플릿을 거친 발견, 그들은 get_bloginfo에서 만든 $의 template_url()

$template_url = str_replace(array('http:', 'https:'), '', get_bloginfo('template_url', 'display')); 

wp_enqueue_script('jquery', false, array(), $version, 'all'); 

wp_register_script("theme-bootstrap", $template_url . '/bootstrap.min.js', array('jquery'), $version); 
wp_enqueue_script("theme-bootstrap"); 

wp_register_script("theme-script", $template_url . '/script.js', array('jquery', 'theme-bootstrap'), $version); 
wp_enqueue_script("theme-script"); 

이 거기를 사용하여 경로를 얻을 수 이 get_bloginfo URL이 문제를 일으키는 이유는 무엇입니까?

답변

0

난 그냥 아이 테마를 인식 나던

$template_url = get_stylesheet_directory_uri(); 

get_bloginfo ('template_url')으로 라인

$template_url = str_replace(array('http:', 'https:'), '', get_bloginfo('template_url', 'display')); 

을 변경하고,이 아이의 주제는 아니지만, 그것은 하위 사이트입니다 , 아마도 그것이 마스터 사이트 URL을로드하는 이유 일 수 있습니다. get_stylesheet_directory는 하위 사이트를 인식하므로 현재있는 사이트의 전체 URL을 사용하므로 내 문제가 해결되었습니다. 보다 우아한 해결책이있을 수 있습니다.

멀티 사이트의 하위 사이트는 자산을 등록 할 때 어떤 측면에서 하위 테마와 비슷하게 처리됩니다.