0
않는 str_replace 함수에서 문자열 변환에 정의되지 않은 변수와 배열을 수정 :나는이 기능을 가지고
// load styles asynchronously - Transform stylesheet markup to loadCSS compatible
add_filter('style_loader_tag', 'style_transform_loadCSS', 10, 2);
function style_transform_loadCSS($html, $handle) {
if ($handle == CHILD_THEME_NAME )
$search = array("rel='stylesheet' id='$handle-css'", "type='text/css' media='all'");
$replace = array("rel=\"preload\"", "as=\"style\" onload=\"this.rel='stylesheet'\"");
return str_replace($search, $replace, $html)."<noscript>{$html}</noscript>";
}
오기 '가 작동을하지만, 디버깅하는 동안이 오류 참조 :
Notice: Undefined variable: search in /home3/me/public_html/wp-content/themes/child/functions.php on line 362
Notice: Array to string conversion in /home3/me/public_html/wp-content/themes/child/functions.php on line 362
라인 (362)입니다 :
return str_replace($search, $replace, $html)."<noscript>{$html}</noscript>";
어떻게 해결할 수 있습니까?
검색 및 바꾸기가 이제는 'if'문과 다른 곳에서 정의됩니다. 이제는 누락 된 var마다 하나씩 두 개의 오류가 발생합니다. –
예 : 나는 더 많은 코드를 추가했습니다. – Stony
테마가 일치하지 않으면'$ html' (str_replace와 같지 않음)을 반환하고 싶다고 가정합니다. 하지만 그것은 단지 가정 일뿐입니다. –