WordPress.org

Support

Support » Plugins and Hacks » Custom menu links bug

Custom menu links bug

  • Hi developer,

    I am facing a bug in the latest 3 versions of your plugin.

    I hope you understand my explanation.

    I have a menu with some custom links. The HREF for all these menu item = #. Below those menu items i have sub items which are linked to real wordpress pages.

    If i am visiting the website and standing on the home page (www.website.com/en) all the custom menu items get the class “current-menu-item”.

    The problem only exists when visiting the home page, not the others.

    I have looked up your code, and noticed this change causes the problems:

    function qtrans_parseURL($url) {
    	$result = parse_url($url);
    	if ($result === false)
    		return __legacy_qtrans_ParseURL($url);
    
    	$result = $result + array(
    			'scheme' => '',
    			'host' => '',
    			'user' => '',
    			'pass' => '',
    			'path' => '',
    			'query' => '',
    			'fragment' => ''
    	);
    
    	if (isset($result['port']))
    		$result['host'] .= ':'. $result['port'];
    
    	return $result;
    }
    
    function __legacy_qtrans_ParseURL($url) {
    	$r  = '!(?:(\w+)://)?(?:(\w+)\:(\w+)@)?([^/:]+)?';
    	$r .= '(?:\:(\d*))?([^#?]+)?(?:\?([^#]+))?(?:#(.+$))?!i';
    
    	preg_match ( $r, $url, $out );
    	$result = @array(
    			"scheme" => $out[1],
    			"host" => $out[4].(($out[5]=='')?'':':'.$out[5]),
    			"user" => $out[2],
    			"pass" => $out[3],
    			"path" => $out[6],
    			"query" => $out[7],
    			"fragment" => $out[8]
    	);
    	return $result;
    }

    This is the structure of my menu:

    home
    custom menu item 1 with url = #
      - Sub item to real page 1
      - Sub item to real page 2
      - Sub item to real page 3
    custom menu item 2 with url = #
      - Sub item to real page 1
      - Sub item to real page 2
      - Sub item to real page 3
    custom menu item 3 with url = #
      - Sub item to real page 1
      - Sub item to real page 2
      - Sub item to real page 3

    The problem stops after replacing this code with the old code from a previous version.

    I hope you are able to fix this bug.

    Kind regards,

    wpetgb

    https://wordpress.org/plugins/mqtranslate/

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom menu links bug’ is closed to new replies.