这个Wordpress工具提示输出功能有什么问题?

时间:2019-04-23 04:59:24

标签: php css wordpress tooltip

我有一个要修复的WordPress插件非常旧,作者没有回答,该插件有很多我已经修复的过期代码。 该插件是用文字显示的工具提示简码。

我遇到了这个问题:激活后,插件会将其添加(输出)到所有帖子:

<html><body><p>

无论您在帖子中写些什么,帖子都会输出上面的HTML。

此输出函数中是否有错误导致此事情发生?这是输出函数:

公共功能box_tooltips_shortcode($ atts,$ text){

    extract(shortcode_atts(
    array(
        "header" =>             "",
        "content" =>            "Tooltip Content",
        "style" =>              $this->default_options["style"],
        "position" =>           $this->default_options["position"],
        "width" =>              "",
        "custom_css_class" =>   "",
        "custom_css" =>         "",
        "custom_content_css" => "",
        "focus" =>              "",
        "tag" =>                $this->default_options["tag"],
        "delay" =>              "",
        "cursor" =>             "",
        "event" =>              "",
        "attr" =>               "",
        ),
        $atts, $text
    ));

    // Prepare atributes:
    if ($focus == 1) {
        $parts = explode("_", $position);
        array_splice($parts, 1, 0, "focus");
        $position = implode("_", $parts);
    }
    $position = "qlabs_tooltip_" . $position;
    $delay = $delay != "" && $delay != 0 ? " delay_" . $delay : "";
    $style = " qlabs_tooltip_" . $style;
    $cursor = $cursor != "" ? " cursor_" . $cursor : "";
    $event = $event != "" ? " event_" . $event : "";
    $custom_css_class = $custom_css_class != "" ? " " . $custom_css_class : "";
    $custom_content_css = $custom_content_css != "" ? " " . $custom_content_css : "";

    // Generate output
    $output = "<{$tag} class='{$position}{$style}{$delay}{$cursor}{$custom_css_class}{$event}' style='{$custom_css}' {$attr} aria-haspopup='true'>";
    $output .= $text;
    $output .= "<span " . ($width != "" ? "style='width: {$width}; {$custom_content_css}' " : "") . " >";
    $output .= $header != "" ? "<strong>{$header}</strong>" : "";
    $output .= $content;
    $output .= "</span>";
    $output .= "</{$tag}>";

    // Check if click event is selected, required for loading JS code
    if( strpos($event, 'click')!==false  ) {
        global $box_tooltips_js;
        $box_tooltips_js = true;
    } 

    return $output;
}

插件无缘无故地将此HTML输出到所有帖子: <html><body><p>

它的简码不能仅正确显示简码的文本。

0 个答案:

没有答案