Php 想在我的wordpress插件中添加$GLOBALS变量,但它不起作用

Php 想在我的wordpress插件中添加$GLOBALS变量,但它不起作用,php,wordpress,Php,Wordpress,最近我正在制作一个wordpress短代码插件。这是一个快速响应的短代码插件。我想从用户输入声明中定制css。因此,我必须为这个atts生成一个$GLOBALS变量,但它不起作用。有人请帮我解决这个问题,因为我想不出是什么问题 <?php function gs_tabs_shortcode($atts, $content= null){ $GLOBALS['tab_count'] = 0; extract(shortcode_atts(array(

最近我正在制作一个wordpress短代码插件。这是一个快速响应的短代码插件。我想从用户输入声明中定制css。因此,我必须为这个atts生成一个$GLOBALS变量,但它不起作用。有人请帮我解决这个问题,因为我想不出是什么问题

    <?php 

function gs_tabs_shortcode($atts, $content= null){
    $GLOBALS['tab_count'] = 0;
    extract(shortcode_atts(array(
      'fontcolor' => '', 
      'tabcolor' => '',
      'contcolor' => '',
      'contfontc' => ''
      ), $atts) );
    $x = $GLOBALS['tab_count'];

     //__User input bind in supper globar array__//
     $GLOBALS['styls'][$x] = array( 'fontcolor' => $fontcolor, 
                                    'tabcolor' => $tabcolor,
                                    'contcolor' => $contcolor,
                                    'contfontc' => $contfontc);
     $GLOBALS['tab_count']++;

    do_shortcode( $content );


    if ( is_array( $GLOBALS['tabs'] ) ) {


        foreach ($GLOBALS['tabs'] as $tab ) {
            $tabs[]= '<li> <i class="fa fa-'.$tab['icon'].' fa-lg "></i>  '.$tab['title'].'  </li>';
            $tabcontent[]= '<div><p> '.$tab['content'].' </p></div>';
        }

        $return = '<div id="horizontalTab">';
        $return .= '<ul class="resp-tabs-list">'.implode( "\n", $tabs ).'</ul>';

        $return .= '<div class="resp-tabs-container">'.implode("\n", $tabcontent).'</div>';
        $return .= '</div>';

    }
    return $return;

}
add_shortcode('gs_tabs', 'gs_tabs_shortcode');

function gs_tabs_shortcode_nested( $atts, $content= null ){
  extract(shortcode_atts(array(
      'title' => '', 
      'icon' => ''
      ), $atts) );

  $x = $GLOBALS['tab_count'];
  $content = do_shortcode($content);
  //__User input bind in supper globar array__//
  $GLOBALS['tabs'][$x] = array( 'title' => $title, 
                                'content' => $content,
                                'icon' => $icon);
  $GLOBALS['tab_count']++;
}
add_shortcode('gs_item','gs_tabs_shortcode_nested');



//customize userdata 
    function my_custom_fonts() {



        if (is_array( $GLOBALS['styls'] ) ) {

            foreach ( $GLOBALS['styls'] as $style ) {
                $opt= '<style>
                .resp-tab-item {
                  background: '.$style['tabcolor'].';
                  color:'.$style['fontcolor'].';
                } 
              </style>';
              echo $opt;
            }

        }


    }
    add_action('wp_head', 'my_custom_fonts');

 ?>

沃克不知道什么?你得到了什么错误?没有错误,但是css dosent如果我分配了任何用户数据,比如我写[gs_tabs fontcolor=“black”tabcolor=“blue”]css dosent会改变,就像以前一样我想你的自定义字体可能会在你的快捷码之前运行。您希望您的my_自定义字体在页脚中运行。使用wp_页脚后,其工作正常,谢谢cooperation@pc情人,我可以建议你在自己的问题上加上答案,把它标记为已解决了吗?你得到了什么错误?没有错误,但是css dosent如果我分配了任何用户数据,比如我写[gs_tabs fontcolor=“black”tabcolor=“blue”]css dosent会改变,就像以前一样我想你的自定义字体可能会在你的快捷码之前运行。您希望您的my_自定义字体在页脚中运行。使用wp_页脚后,其工作正常,谢谢cooperation@pc爱人,我可以建议你在自己的问题上加上答案,把它标记为已经解决了吗
//customize userdata 
    function my_custom_fonts() {

        if (is_array( $GLOBALS['styls'] ) ) {

            foreach ( $GLOBALS['styls'] as $style ) {
                $opt= '<style>
                .resp-tab-item {
                  background: '.$style['tabcolor'].';
                  color:'.$style['fontcolor'].';
                } 
              </style>';
              echo $opt;
            }
        }

    }
    add_action('wp_head', 'my_custom_fonts');
[gs_tabs fontcolor="black" tabcolor="blue"  ]

[gs_item title="item1" icon="camera-retro"]this is item 1[/gs_item]
[gs_item title="item2"  ]this is item 2[/gs_item]
[gs_item title="item3" icon="binoculars"]this is item 3[/gs_item]

[/gs_tabs]