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

严格的标准:在第116行的wordpress/wp includes/class-oembed.php中,只能通过引用传递变量,php,wordpress,audio,oembed,Php,Wordpress,Audio,Oembed,我已经看过很多类似的问题,但我不明白,关于我的代码 错误: 严格的标准:在第116行的wordpress/wp includes/class-oembed.php中,只能通过引用传递变量 这是我的代码 // Get Ready Display the Audio $embedCheck = array("<embed", "<ifram");// only checking against the first 6 $mykey_values = get_post_cu

我已经看过很多类似的问题,但我不明白,关于我的代码

错误:

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

这是我的代码

// 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

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

你可以这样写:

$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>');
$content\u oembed=(wp\u oembed\u get($url)!==false)
? (“”.wp_oembed_get($url)。“”)
: ('');

目前,我避免使用wp\u oembed\u get,方法是切换我的条件,如果它不是iframe,或者使用下面的命令来确定它是本地托管的,还是自动嵌入的链接

global $wp_embed;
$post_embed = $wp_embed->run_shortcode('[embed]'.$url.'[/embed]');

然后echo'ing$post_embed

当您显示代码并给我们一个行号时,请帮我们在代码中标记它。只是一条评论说,
//这是第116行
或其他什么。嘿,Swerri-抱歉混淆-行号在wordpress包含的名为class-oembed.php的文件中-但是错误是由我在这里专门围绕该函数wp_oembed_getGreat tip可能的重复引起的-谢谢,你认为这就是抛出错误的原因,还是这只是使用三元运算符的一般提示?@pushplaybang它很可能会导致你的错误,但第116行到底是什么?wordpress include class-oembed.php中的第116行。我正在使用的函数wp_oembed_get()来查看wordpress是否可以在那里嵌入链接引用了一些东西-我确实看了一下,这对我来说没有意义,而且如果我删除了这几个链接,错误也不会持续lines@pushplaybang你对我发布的修改过的代码还有错误吗?
global $wp_embed;
$post_embed = $wp_embed->run_shortcode('[embed]'.$url.'[/embed]');