• Resolved jgoldberg2013

    (@jgoldberg2013)


    Responsive Theme with child theme. https://www.help-alliance.de
    Level of PHP is zero.
    I have tried a number of times to insert the code provided into various placs but I keep getting a parse error.
    Code inserted is if ( function_exists ( 'the_msls' ) ) the_msls()
    you mention place this in functions.php.
    There are two functions.php files.
    1 in main dir of theme – code is.

    * WARNING: Please do not edit this file in any way
     *
     * load the theme function files
     */
    require ( get_template_directory() . '/includes/functions.php' );
    require ( get_template_directory() . '/includes/theme-options.php' );
    require ( get_template_directory() . '/includes/post-custom-meta.php' );
    require ( get_template_directory() . '/includes/tha-theme-hooks.php' );
    require ( get_template_directory() . '/includes/hooks.php' );
    require ( get_template_directory() . '/includes/version.php' );

    2 in functions.php in theme dir/includes – code relating to main-nav is `/**

    * This feature enables custom-menus support for a theme.
             * @see https://codex.www.ads-software.com/Function_Reference/register_nav_menus
             */
            register_nav_menus(array(
    			'top-menu'         => __('Top Menu', 'responsive'),
    	        'header-menu'      => __('Header Menu', 'responsive'),
    	        'sub-header-menu'  => __('Sub-Header Menu', 'responsive'),
    			'footer-menu'      => __('Footer Menu', 'responsive')
    		    )
    	    );
    
    		if ( function_exists('get_custom_header')) {

    Alternative is the header.php file but I still cant get the flags to show in the menu bar itself..
    This is the header.php code:

    <?php get_sidebar('top'); ?>
    				<?php wp_nav_menu(array(
    				    'container'       => 'div',
    						'container_class'	=> 'main-nav',
    						'fallback_cb'	  =>  'responsive_fallback_menu',
    						'theme_location'  => 'header-menu')
    													);
    						?>

    I have spent a few hours on this trying to figure this out without support but I feel I am out of league when php coding is at work.

    https://www.ads-software.com/extend/plugins/multisite-language-switcher/

Viewing 15 replies - 1 through 15 (of 21 total)
  • Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Same question – trouble with code input

    Sorry, what are you trying to accomplish? “Same question” isn’t very descriptive.

    Thread Starter jgoldberg2013

    (@jgoldberg2013)

    Sorry Jan.
    I hve read alot of the feeds regarding to try and get the multisite language swtcher in my main navigation bar.
    The plugin provides widget that sits ontop of nav bar and all the advise I have tried to follow had not helped me.

    the plug in site oes give advise to how to do this but I am very confused as to where and how to insert this to acheive my goal.
    their support link is https://github.com/lloc/Multisite-Language-Switcher/wiki.
    My details are above for your veiwing.
    I really do hope you can help, this is the last step in my website. Thansk in advance for any guidance.

    Thread Starter jgoldberg2013

    (@jgoldberg2013)

    also to add – this is a post that the theme support provides to get a thier serch widget in the main nav area.
    Copy header.php from Responsive to Responsive Child Theme and add this in:

    <div id="search-box">
                <?php get_search_form(); ?>
            </div><!-- end of #search-box -->

    I thought I could just replace theirs with the code the language swtcher provided but keep getting parse errors.

    Plugin Author Dennis Ploetner

    (@realloc)

    There is a brief description here:

    https://github.com/lloc/Multisite-Language-Switcher/wiki/Generate-the-output#manipulate-the-navigation-menu

    It seems that you should use the second functions.php when you want to insert some code. The menu in your header.php has the theme_location header-menu. So I would use something like this

    function my_custom_menu_item( $items, $args ) {
        if ( class_exists( 'MslsOutput' ) && 'header-menu' == $args->theme_location ) {
            $obj = new MslsOutput;
            $arr = $obj->get( 2 );
            if ( !empty( $arr ) ) {
                $items .= '<li>' . implode( '</li><li>', $arr ) . '</li>';
            }
        }
        return $items;
    }
    add_filter( 'wp_nav_menu_items', 'my_custom_menu_item', 10, 2 );

    Hope this helps.

    Cheers,
    Dennis.

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Sorry Jan.

    Nothing to be sorry for. ??

    I hve read alot of the feeds regarding to try and get the multisite language swtcher in my main navigation bar.

    That’s better.

    You do have a multisite installation right?

    Try creating a child theme and modify your child theme’s copy of the header.php file and put these lines in it.

    <!-- Multisite Language Switcher START -->
    <?php if ( function_exists( 'the_msls' ) ) the_msls(); ?>
    <!-- Multisite Language Switcher END -->

    Then load up your web site and view the HTML. At a minimum you should see those comments in the HTML. This will let you test if the function the_msls() is even active or not.

    Thread Starter jgoldberg2013

    (@jgoldberg2013)

    Hi Dennis – thanks for quick response. Very impressed with plug in and now your support.
    I have read the link a number of times now but still not having any luck – I keep getting a parse error on the lines I dumped in.

    You mention both the functions.php and the header.php
    Which one do I place your code into – this is what is confusing.
    I have placed your code as above in the 2nd functions.php loacted in theme/includes/…
    This is the code but it did nothing to the site. https://help-alliance.de

    * This feature enables custom-menus support for a theme.
             * @see https://codex.www.ads-software.com/Function_Reference/register_nav_menus
             */
            register_nav_menus(array(
    			'top-menu'         => __('Top Menu', 'responsive'),
    	        'header-menu'      => __('Header Menu', 'responsive'),
    	        'sub-header-menu'  => __('Sub-Header Menu', 'responsive'),
    			'footer-menu'      => __('Footer Menu', 'responsive')
    		    )
    	    );
    function my_custom_menu_item( $items, $args ) {
        if ( class_exists( 'MslsOutput' ) && 'header-menu' == $args->theme_location ) {
            $obj = new MslsOutput;
            $arr = $obj->get( 2 );
            if ( !empty( $arr ) ) {
                $items .= '
    <li>' . implode( '</li>
    <li>', $arr ) . '</li>
    ';
            }
        }
        return $items;
    }
    add_filter( 'wp_nav_menu_items', 'my_custom_menu_item', 10, 2 );
    
    		if ( function_exists('get_custom_header')) {</a>

    [Please post code & markup between backticks or use the code button. Your posted code has now been permanently damaged by the forum’s parser.]

    Thread Starter jgoldberg2013

    (@jgoldberg2013)

    Jan- yes multisite is set-up and the plugin is active and working. That is not the issue – The plugin author has stepped (as above) in to assist kindly so thanks for your advise though.

    Plugin Author Dennis Ploetner

    (@realloc)

    Just add the code to the second functions.php and it will add your flags automatically to the menu.

    Thread Starter jgoldberg2013

    (@jgoldberg2013)

    I dumped your code into 2nd functions.php file adsaved it in my child theme directory.
    This is what comes back to me when going to URL.
    Fatal error: Cannot redeclare responsive_get_options() (previously declared in /homepages/29/d125184200/htdocs/en/wp-content/themes/coinlogistics_child/functions.php:38) in /homepages/29/d125184200/htdocs/en/wp-content/themes/responsive/includes/functions.php on line 43

    ————————————————————
    If I save the edited file in the theme/includes directory then nothing happens.
    ———————————————————–
    I placed the code as so:

    /**
     * Set a fallback menu that will show a home link.
     */
    
    function responsive_fallback_menu() {
    	$args = array(
    		'depth'       => 0,
    		'sort_column' => 'menu_order, post_title',
    		'menu_class'  => 'menu',
    		'include'     => '',
    		'exclude'     => '',
    		'echo'        => false,
    		'show_home'   => false,
    		'link_before' => '',
    		'link_after'  => ''
    	);
    	$pages = wp_page_menu( $args );
    	$prepend = '<div class="main-nav">';
    	$append = '</div>';
    	$output = $prepend.$pages.$append;
    	echo $output;
    }
    
    function my_custom_menu_item( $items, $args ) {
        if ( class_exists( 'MslsOutput' ) && 'header-menu' == $args->theme_location ) {
            $obj = new MslsOutput;
            $arr = $obj->get( 2 );
            if ( !empty( $arr ) ) {
                $items .= '<li>' . implode( '</li><li>', $arr ) . '</li>';
            }
        }
        return $items;
    }
    add_filter( 'wp_nav_menu_items', 'my_custom_menu_item', 10, 2 );
    /**
     * This function removes .menu class from custom menus
     * in widgets only and fallback's on default widget lists
     * and assigns new unique class called .menu-widget
     *
     * Marko Heijnen Contribution
     *
     */
    class responsive_widget_menu_class {
    	public function __construct() {

    Thread Starter jgoldberg2013

    (@jgoldberg2013)

    OK – thought I had a light bulb moment and removed the MLS widget out and – ALL gone now. no flags at all.

    Plugin Author Dennis Ploetner

    (@realloc)

    Please use just my code:

    function my_custom_menu_item( $items, $args ) {
        if ( class_exists( 'MslsOutput' ) && 'header-menu' == $args->theme_location ) {
            $obj = new MslsOutput;
            $arr = $obj->get( 2 );
            if ( !empty( $arr ) ) {
                $items .= '<li>' . implode( '</li><li>', $arr ) . '</li>';
            }
        }
        return $items;
    }
    add_filter( 'wp_nav_menu_items', 'my_custom_menu_item', 10, 2 );

    You copied other code too. responsive_get_options() for example…

    Thread Starter jgoldberg2013

    (@jgoldberg2013)

    I placed your code EXACTLY at the END of the functions.php file
    in the theme/includes folder.
    AND NOTHING changed. do I need to edit your code in anay way?
    Do I remove your widget from the dashboard from all sites on network?
    I am really stuck here- I do hope we can sort this out.
    These are the last lines on the funcion.php file.

    }
    function my_custom_menu_item( $items, $args ) {
        if ( class_exists( 'MslsOutput' ) && 'header-menu' == $args->theme_location ) {
            $obj = new MslsOutput;
            $arr = $obj->get( 2 );
            if ( !empty( $arr ) ) {
                $items .= '<li>' . implode( '</li><li>', $arr ) . '</li>';
            }
        }
        return $items;
    }
    add_filter( 'wp_nav_menu_items', 'my_custom_menu_item', 10, 2 );
    add_filter( 'body_class','responsive_add_class' );
    ?>

    Thread Starter jgoldberg2013

    (@jgoldberg2013)

    I even tried your code in the header.php at the end of the page but still nothing changes.
    I have really run out of options and is frustrated as this seems very easy to implemnt but after hours of trying – I am only failing.

    Plugin Author Dennis Ploetner

    (@realloc)

    My code can just work if you place it in the functions.php and not in the header.php. You should check if header-menu is the right menu or if you have to use another menu like top-menu, sub-header-menu (or footer-menu)…

    Thread Starter jgoldberg2013

    (@jgoldberg2013)

    Hi Dennis, thanks for being so patient with me but I still can not get switcher in the main-nav.
    I have done exactly what you have asked.
    I have tried it with the switcher widget placed in a widget area
    AND with it out of any widget area.
    Either way still nothing.
    I know the “main”nav is the class as it says so in firebug html.
    snapshot of info can be seen at https://postimg.org/image/8fv8f1zp3/
    I know zero about php so I am really stuck if you say that your code MUST work and it does not.

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘Same question – trouble with code input’ is closed to new replies.