WordPress.org

Ready to get started?Download WordPress

Forums

Menu
How to set the class attribute in anchors to use a jQuery script (2 posts)

  1. supergiu
    Member
    Posted 3 years ago #

    How to set the class attribute in anchors to use a jQuery script?
    I use Menu plugin v1.0.

    I need the <a class="anchorLink"> attribute to use this script.

    Any ideas?
    Thanks

    supergiĆ¹

    http://wordpress.org/extend/plugins/menu/

  2. supergiu
    Member
    Posted 3 years ago #

    Hello,
    Can anyone help me?

    I have looked into plugin's files and I have found these pieces of code that perhaps can be used to do something:

    in menu.php on line 106 I have found

    private function renderMenuItem($item,$count = 99) {
    			$class = $this->getItemClass($item,$count);
    			$output = '<li class="' . $class . '"><a class="' . $class . '" href="' . $this->getItemUrl($item) . '">' . esc_html($item['label']) . '</a></li>';
    			return $output;
    		}

    while in views/settings.php on line 36

    <td>
    	<label><span><?php _e( 'Label' ); ?></span> <input type="text" class="regular-text" name="menu[label][]" value="<?php echo esc_attr($item['label']); ?>" /></label>
    	<label><span><?php _e( 'URL' ); ?></span> <input type="text" class="regular-text" name="menu[url][]" value="<?php echo esc_attr($item['url']); ?>" /></label>
    	<label><span><?php _e( 'CSS Class' ); ?></span> <input type="text" class="regular-text" name="menu[class][]" value="<?php echo esc_attr($item['class']); ?>" /></label>
    </td>

    What I have thought is that if we could create a new variable to replace $class in

    <a class="' . $class . '" href="' . $this->getItemUrl($item) . '">

    then we could add a new input field in settings.php, something like this

    <label><span><?php _e( 'A Class' ); ?></span> <input type="text" class="regular-text" name="menu[aclass][]" value="<?php echo esc_attr($item['aclass']); ?>" /></label>

    Sorry for my Bad English...
    If anyone has understood, can help me understand?

    Thanks
    supergiĆ¹

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic