在PHP文件中插入一个函数

时间:2019-05-27 11:54:24

标签: php function wpml

我需要添加此功能:

< ? php do_action('wpml_add_language_selector'); ?>

在XXXX所在的行:

<div class="selettore-lingua">XXXX</div>

但是我从PHP中得到一个错误,并且功能不起作用。有什么想法要解决吗?谢谢

case 'hmenu-center':
    $this->html = '<div class="menu-wrapper'.$menu_sticky.$menu_no_arrow.$menu_sub_animation.' style-'.$stylemain.'-original">'.
        ($no_secondary !== 'on' ? $secondary_menu_html : '').
        '<div class="navbar menu-secondary'.$stylemaincombo.$main_absolute.'">
            <div class="menu-container-mobile '.$effects.$stylemainbackfull.'">
                <div class="row-menu style-'.$stylemain.'-bg">
                    <div class="row-menu-inner">
                        <div id="logo-container-mobile" class="col-lg-0 logo-container">
                            <div id="main-logo" class="navbar-header style-'.$stylemain.'">'.$logoDiv.
                            '</div>
                        </div>
                    </div>
                    <div class="mmb-container">YO'.$woo_icon_mobile.
                        '<div class="mobile-menu-button '.$buttonstyle_primary.' lines-button x2"><span class="lines"></span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <header id="masthead" class="navbar'.$stylemaincombo.'">
            <div class="menu-container'.$effects.$stylemainbackfull.'">
                <div class="row-menu'.$main_width.'">
                    <div class="row-menu-inner'.$stylemainback.'">
                        <div class="col-lg-12 main-menu-container middle">
                            <div class="menu-horizontal' . $sub_shadows . '">
                                <div class="menu-horizontal-inner">
                                                                            '.
wp_nav_menu( array("menu" => $primary_menu,
                   "theme_location"    => "primary",
                    "container"         => "div",
                    "container_class"   => "nav navbar-nav navbar-main " . 

(($search !== '' || $cta_menu) ? 'navbar-nav-first' : 'navbar-nav-last') ,
                                                                                "menu_class"        => "menu-primary-inner menu-smart".(is_rtl() ? ' sm-rtl' : '')." sm",
                                                                                "fallback_cb"       => false,
                                                                                "walker"            => new wp_bootstrap_navwalker(),
                                                                                "echo"            => 0)
                                                                            );

                                                                            if ( $cta_menu ) {
                                                                                $this->html .= wp_nav_menu( array(
                                                                                    "menu"              => $cta_menu,
                                                                                    "theme_location"    => "cta",
                                                                                    "container"         => "div",
                                                                                    "container_class"   => "nav navbar-nav navbar-cta" . ( ( $search === '' ) ? ' navbar-nav-last' : '' ),
                                                                                    "menu_class"        => "menu-cta-inner menu-smart".(is_rtl() ? ' sm-rtl' : '')." sm",
                                                                                    "fallback_cb"       => "wp_bootstrap_navwalker::fallback",
                                                                                    "walker"            => new wp_bootstrap_navwalker(),
                                                                                    "echo"            => 0)
                                                                                );
                                                                            }

                                                                            $this->html .= ($search !== '' ? '<div class="nav navbar-nav navbar-nav-last">'.$search.'</div>' : '');
                if ($no_secondary !== 'on') {
                        $this->html .=                      '<div class="desktop-hidden">
                                                                                '.wp_nav_menu( array(
                                                                                    "menu"              => $secondary_menu,
                                                                                    "theme_location"    => "secondary",
                                                                                    "container"         => "div",
                                                                                    "container_class"   => "menu-accordion",
                                                                                    "menu_class"        => "menu-smart".(is_rtl() ? ' sm-rtl' : '')." sm sm-vertical mobile-secondary-menu",
                                                                                    'fallback_cb'    => false,
                                                                                    "walker"            => new wp_bootstrap_navwalker(),
                                                                                    "echo"            => 0)
                                                                                ).
                                                                            '</div>';
                }
                    $this->html .=                      '</div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </header>
                                            </div>';
                break;

            case 'hmenu-center-split':
                global $logo_html;
                $logo_html = '<div class="logo-container megamenu-diff middle">
                                                <div id="main-logo" class="navbar-header style-'.$stylemain.'">
                                                    '.$logoDiv.'
                                                </div>
                                                <div class="mmb-container"><div class="mobile-menu-button '.$buttonstyle_primary.' lines-button x2"><span class="lines"></span></div></div>
                                            </div>';
                add_filter('wp_nav_menu_objects', 'uncode_center_nav_menu_items', 10, 2);
                $this->html = '<div class="menu-wrapper'.$menu_shrink.$menu_sticky.$menu_no_arrow.$menu_sub_animation.'">
                                                '.($no_secondary !== 'on' ? $secondary_menu_html : '').'
                                                <header id="masthead" class="navbar'.$stylemaincombo.$main_absolute.' menu-with-logo">
                                                    <div class="menu-container'.$effects.$stylemainbackfull.'">
                                                        <div class="row-menu'.$main_width.'">
                                                            <div class="row-menu-inner'.$stylemainback.'">
                                                                <div id="logo-container-mobile" class="col-lg-0 logo-container megamenu-diff desktop-hidden">
                                                                    <div class="navbar-header style-'.$stylemain.'">
                                                                        '.$logoDiv.'
                                                                    </div>
                                                                    <div class="mmb-container">'.$woo_icon_mobile.'<div class="mobile-menu-button '.$buttonstyle_primary.' lines-button x2"><span class="lines"></span></div></div>
                                                                </div>
                                                                <div class="col-lg-12 main-menu-container middle">
                                                                    <div class="menu-horizontal' . $sub_shadows . '">
                                                                        <div class="menu-horizontal-inner">';
                    if ($social_html_inner !== '') {
                        $this->html .=                      '<div class="nav navbar-nav navbar-social navbar-nav-first">
                                                                <ul class="menu-smart'.(is_rtl() ? ' sm-rtl' : '').' sm menu-icons mobile-hidden tablet-hidden">
                                                                    '.$social_html_inner.'
                                                                </ul>
                                                            </div>';
                    }

                                                            if ( $cta_menu ) {
                                                                $this->html .= wp_nav_menu( array(
                                                                    "menu"              => $cta_menu,
                                                                    "theme_location"    => "cta",
                                                                    "container"         => "div",
                                                                    "container_class"   => "nav navbar-nav navbar-cta hmenu-center-split-child" . ( ( $social_html_inner === '' ) ? ' navbar-nav-first' : '' ),
                                                                    "menu_class"        => "menu-primary-inner menu-smart".(is_rtl() ? ' sm-rtl' : '')." sm",
                                                                    "fallback_cb"       => "wp_bootstrap_navwalker::fallback",
                                                                    "walker"            => new wp_bootstrap_navwalker(),
                                                                    "echo"            => 0)
                                                                );
                                                            }

                        $this->html .=                      wp_nav_menu( array(
                                                                                "menu"              => $primary_menu,
                                                                                "theme_location"    => "primary",
                                                                                "container"         => "div",
                                                                                "container_class"   => "nav navbar-nav navbar-main",
                                                                                "menu_class"        => "menu-primary-inner menu-smart".(is_rtl() ? ' sm-rtl' : '')." sm",
                                                                                "fallback_cb"       => false,
                                                                                "walker"            => new wp_bootstrap_navwalker(),
                                                                                "echo"            => 0)
                                                                            );

                    if ($search !== '') {
                        $this->html .=                      '<div class="nav navbar-nav navbar-nav-last">'.$search.'</div>';
                    }

                    if ($no_secondary !== 'on') {
                        $this->html .=                      '<div class="desktop-hidden">
                                                                                '.wp_nav_menu( array(
                                                                                    "menu"              => $secondary_menu,
                                                                                    "theme_location"    => "secondary",
                                                                                    "container"         => "div",
                                                                                    "container_class"   => "menu-accordion",
                                                                                    "menu_class"        => "menu-smart".(is_rtl() ? ' sm-rtl' : '')." sm sm-vertical mobile-secondary-menu",
                                                                                    'fallback_cb'    => false,
                                                                                    "walker"            => new wp_bootstrap_navwalker(),
                                                                                    "echo"            => 0)
                                                                                ).
                                                                            '</div>';
                    }
                    $this->html .=                      '</div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </header>
                                            </div>';
                break;

            case 'offcanvas_head':
                $this->html = '<div class="menu-wrapper'.$menu_shrink.$menu_sticky.'">
                                                <div id="masthead" class="navbar'.$stylemaincombo.$main_absolute.' menu-with-logo">
                                                    <div class="menu-container'.$effects.$stylemainbackfull.'">
                                                        <div class="row-menu row-offcanvas'.$main_width.'">
                                                            <div class="row-menu-inner row-brand menu-horizontal-inner'.$stylemainback.'">';
                if ($param == 'menu-overlay-center' && $search !== '') {
                    $this->html .=              '<div class="nav navbar-nav navbar-nav-first">
                                                                    '.$search.'
                                                                </div>';
                }
                $this->html .=                  '<div id="logo-container-mobile" class="col-lg-0 logo-container middle"><div class="selettore-lingua">XXXX</div>

                                                                    <div id="main-logo" class="navbar-header style-'.$stylemain.'">
                                                                        '.$logoDiv.'


                                                                    </div>
                                                                </div>
                                                                <div class="mmb-container">'.$woo_icon_mobile.'<div class="'.(($param == 'menu-overlay' || $param == 'menu-overlay-center') ? 'mobile-menu-button menu-button-overlay no-toggle' : 'mobile-menu-button menu-button-offcanvas').' '.$buttonstyle_primary.' lines-button x2 trigger-overlay" '.(($param == 'menu-overlay' || $param == 'menu-overlay-center') ? 'data-area="menu" data-container="main-container"' : '').'><span class="lines"></span></div></div>';


                                                            if ( $cta_menu ) {
                                                                $this->html .= '<div class="col-lg-12 main-menu-container cta-container middle' . $menu_sub_animation . $menu_no_arrow . '">
                                                                    <div class="menu-horizontal' . $sub_shadows . '">
                                                                        <div class="menu-horizontal-inner">
                                                                            '.wp_nav_menu( array(
                                                                                "menu"              => $cta_menu,
                                                                                "theme_location"    => "cta",
                                                                                "container"         => "div",
                                                                                "container_class"   => "nav navbar-nav navbar-cta",
                                                                                "menu_class"        => "menu-cta-inner menu-smart".(is_rtl() ? ' sm-rtl' : '')." sm",
                                                                                "fallback_cb"       => "wp_bootstrap_navwalker::fallback",
                                                                                "walker"            => new wp_bootstrap_navwalker(),
                                                                                "echo"            => 0)
                                                                            ).
                                                                        '</div>
                                                                    </div>
                                                                </div><!-- .main-menu-container -->';
                                                            }

                                                    $this->html .= '</div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>';
                break;

0 个答案:

没有答案