2016-10-03 95 views
-1

我不知道如何说出问题。我不是PHP的专家。我正在尝试编辑一个热点插件。我有这样的代码仅回显阵列外部的阵列的一部分

function ult_hotspot_items_callback($atts, $content = null){ 
     global $hotspot_icon, $hotspot_icon_bg_color, $hotspot_icon_color, $hotspot_icon_size; 

     extract(shortcode_atts(array(
      'hotspot_content'     => '', 
      'hotspot_label'      => '', 
      'hotspot_position'     => '0,0', 
      'tooltip_content'     => '', 
      'tooltip_width'      => '300', 
      'tooltip_padding'     => '', 
      'tooltip_position'     => '', 
      "icon_type"       => '', 
      'icon'        => 'Defaults-map-marker', 
      'icon_color'      => '', 
      'icon_style'      => '', 
      'icon_color_bg'      => '', 
      'icon_border_style'     => '', 
      'icon_color_border'     => '', 
      'icon_border_size'     => '', 
      'icon_border_radius'    => '', 
      'icon_border_spacing'    => '', 
      'icon_img'       => '', 
      'img_width'       => '60', 
      'link_style'      => '', 
      'icon_link'       => '', 
      'icon_size'       => '', 
      "alignment"       => "center", 
      'tooltip_trigger'     => '', 
      'tooltip_animation'     => '', 
      'tooltip_continuous_animation'  => '', 
      'glow_color'      => '', 
      'enable_bubble_arrow'    => 'on', 
      'tooltip_custom_bg_color'   => '#fff', 
      'tooltip_custom_color'    => '#4c4c4c', 
      'tooltip_font'      => '', 
      'tooltip_font_style'    => '', 
      'tooltip_font_size'     => '', 
      'tooltip_font_line_height'   => '', 
      'tooltip_custom_border_size'  => '', 
      'tooltip_align'      => '', 
     ), $atts) ); 

我想REFFERENCE /电话/呼应只是“‘tooltip_content’”该数组的数组在页面上其他地方之外的结果。我该如何去做呢?

谢谢。

不幸的是,有字符数限制我想分享所有的页面代码,但它不会让我

+0

它是imp可以用你提供的东西回答这个问题。正如它表明数组只在函数内部定义的,并且不能在其外部访问。 – trincot

+0

好吧然后我可以创建另一个变量引用该数组或复制它,只是从tooltip_content获取信息? – user3438298

+0

我不太明白你想要什么,因为你包含的PHP代码有一个硬编码的'tooltip_content'值,即空白。只有它是动态的,它才有用。注意:你不需要共享你的所有代码,只需要分享必要的部分。例如,我们不需要知道该数组的其他30个键/值。 – trincot

回答

0

由于你的代码是不是很清楚,但在我看来,你是设置一个值$tooltip_content。如果是这样,是的,正如你将它定义为全局一样,所以它可以在函数外面使用。

+0

你可以给上我怎么会写了 – user3438298

+0

作为你的功能尚不清楚的例子,但这里有一个简单的例子:功能callbackfun(){ 全球$ tooltip_content; \t \t $ tooltip_content ='dfgfhfgh'; \t \t echo $ tooltip_content \t; } callbackfun($ atts,$ content = null); echo“>>>>>>>>>>>>>>>>>”。$ tooltip_content \t; –

+0

我不明白全功能应该如何重要。我需要做的就是显示在wordpress后端编写的工具提示。我已经把它缩小到数组'tooltip_content' - 我如何参考甚至创建一个新的数组/变量来显示这些信息?发布时有一个字符限制,它不会让我分享完整的功能 – user3438298

0

好吧我想通了。它与阵列完全没有关系。你们是对的。对于这样一个令人困惑的帖子,我真的很抱歉。就像我说的我不是PHP专家。我需要的是变量$ content或$ hotspot_content。当我用它来渲染内容和添加的html标签和样式时,因为输出进一步在页面下方。所以它几乎将<ul><li>到输出,然后调用它

$tip_content = $content; $output = '<div class="wpb_text_column wpb_content_element mobile"><div class="wpb_wrapper"><ul>' . strip_tags ($tip_content, '<li>') . "</ul></div></div>";

和REFFERENCE的含量进一步下降称为页面

if($link_style == 'link'){ 
      $output .= " <a data-link_style='simple' class='ult-tooltip ult-tooltipstered ult-hotspot-tooltip' href='".$url."' ".$link_title." ".$target." data-status='hide'>"; 
      $output .= $icon_inline; 
      $output .= " </a>"; 
     } else { 
      $output .= " <a data-link_style='tootip' ".$data." class='ult-tooltip ult-tooltipstered ult-hotspot-tooltip' href='#' data-status='show'>"; 
       $output .= $icon_inline; 
       $output .= "<span class='hotspot-tooltip-content'><ul><li>".esc_html(str_replace('"', '\'', $hotspot_content))."</li></ul></span>"; 
      $output .= " </a>"; 
     } 

     $output .= " </div><!-- ICON WRAP -->"; 

     $output .= $glow; 

     $output .= "</div>"; 
     return $output; 
    } 

我不能骑过的样式但就像我说的,我刚刚添加列表给他们,当他们在页面上单独打电话时,我只是使用strip_tags ($tip_content, '<li>') strip_tags函数来停止输出除列表之外的所有其他代码