gpt4 book ai didi

php - 严格的标准:仅应在第116行的wordpress/wp-includes/class-oembed.php中通过引用传递变量

转载 作者:行者123 更新时间:2023-12-02 22:41:20 26 4
gpt4 key购买 nike

关于我的代码,我已经看过很多类似的问题,但我并没有理解。

错误 :
Strict Standards: Only variables should be passed by reference in wordpress/wp-includes/class-oembed.php on line 116

这是我的代码...

// Get Ready Display the Audio
$embedCheck = array("<embed", "<ifram");// only checking against the first 6
$mykey_values = get_post_custom_values('_format_audio_embed');
$content_oembed = '';

// check if the audio metabox is used
if ( isset($mykey_values) && !empty($mykey_values) ) {
// iterate over values passed
foreach ( $mykey_values as $key => $value ) {
$url = $value;
$wtf = wp_oembed_get($url);
if ( !empty($url) ) {
$firstCar = substr($url, 0, 6); // get the first 6 char.

// if its a http(s).
if ( strpos($firstCar, "http:/" ) !== false || strpos($firstCar, "https:" ) !== false ) {
// send it to wp_oembed to see if the link is oembed enabled.


$content_oembed = ($wtf !==false)
? ('"<div class="audio" style="width:100%; overflow:hidden;">' .$wtf.'</div>')
: ('<audio src="'.$url.'" preload="none" type="audio/mpeg"></audio>');
}

// if its the embed code that matches our array defined above.
else if ( audio_strpos_arr($firstCar, $embedCheck ) !== false ) {
$content_oembed = '<div class="video" style="width:100%; overflow:hidden;">' .$url. '</div>';

}
}
}; // end foreach
} // end conditional

如果我删除注释下面条件栏中的部分“将其发送到wp_oembed,以查看该链接是否已启用链接。”,但如果我将其传递给soundcloud链接,仍然很陌生-没有错误,但是如果它是本地托管文件,它将消失山雀。

任何帮助将不胜感激。

经过一番摸索-似乎问题与该函数 http://codex.wordpress.org/Function_Reference/wp_oembed_get有关

以及在incldued class-oembed.php中引用的内容在第116行说了以下内容
112         function discover( $url ) {
113 $providers = array();
114
115 // Fetch URL content
116 if ( $html = wp_remote_retrieve_body( wp_safe_remote_get( $url ) ) ) {

最佳答案

您不应该在三元表达式中使用赋值(=),因为这样会遇到运算符优先级的问题。

您可以这样写:

$content_oembed = (wp_oembed_get($url) !==false)
? ('<div class="audio" style="width:100%; overflow:hidden;">' . wp_oembed_get($url).'</div>')
: ('<audio src="'.$url.'" preload="none" type="audio/mpeg"></audio>');

关于php - 严格的标准:仅应在第116行的wordpress/wp-includes/class-oembed.php中通过引用传递变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18041225/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com