• lewismalpas

    (@lewismalpas)


    Hi,

    I am using the iA WordPress theme and the menu dynamically highlights on all pages besides the page I have selected as the posts page within the dashboard.

    Within the themes function.php there is a function which wraps the menu item with a strong tag which is then styled using CSS. The function prevents the menu item for the posts page from being wrapped with the strong tag, any ideas how I can change the function so all of the pages are dynamically highlighted?

    Here is the function:

    static function get_nav_cell($key = '', $default = '') {
        $array = array();
        $value = ia3_helpers::get_option($key);
    
        if ($value == '') return $default;
    
        if (preg_match("/^c\-(.*)/", $value, $array)) {
            $item = ia3_helpers::get_category($array[1]);
    
    		$item_i = isset($item->cat_ID)? $item->cat_ID: 0;
    		$item_n = isset($item->name)? $item->name: __('Unknown', 'ia3');
    		$item_l = get_category_link($item_i);
    
    		if ((strpos($item_l . '***', $_SERVER['REQUEST_URI'] . '***')) && (!is_home())) {
                return '<strong><a href="' . $item_l . '">' . $item_n . '</a></strong>';
            } else {
                return '<a href="' . $item_l . '">' . $item_n . '</a>';
            }
    
    	} else if (preg_match("/^p\-(.*)/", $value, $array)) {
    	    $item = ia3_helpers::get_page($array[1]);
    
    		$item_i = isset($item->ID)? $item->ID: 0;
    		$item_n = isset($item->post_title)? $item->post_title: __('Unknown', 'ia3');
    		$item_l = get_page_link($item_i);
    
    		if ((strpos($item_l . '***', $_SERVER['REQUEST_URI'] . '***')) && (!is_home())) {
                return '<strong><a href="' . $item_l . '">' . $item_n . '</a></strong>';
            } else {
                return '<a href="' . $item_l . '">' . $item_n . '</a>';
            }
    	} else {
    	    $item_l = stripslashes($value);
    	    $item_u = array();
    
    	    if (preg_match("/^<a(.+)href=\"(.+)\"(.+)<\/a>$/", $item_l, $item_u)) {
    
    	        if (isset($item_u[2]) && strpos($item_u[2] . '***', $_SERVER['REQUEST_URI'] . '***')) {
                    return '<strong>' . $item_l . '</strong>';
                } else {
                    return $item_l;
                }
    	    }
    
            return $item_l;
        }
    }

    Many thanks for your help,

    Lewis.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Dynamic Menu Highlighting’ is closed to new replies.