javascript - What does "array must have exactly two members" mean? -


i trying set custom walker wordpress menu. purpose allow me add php code menu links text , images this:

<a href="http://mcadrives.com/?ref=<?php code goes here?>"> 

the php coding have been using on every hyperlink , image this:

<a href="http://mcadrives.com/?ref=     <?php        if (!empty ( $_server['query_string'])){          echo substr($_server['query_string'],4); }        else{           echo 'mhammonds'; }     ?>> 

i added functions.php file:

class query_nav extends walker_nav_menu {     function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {         global $wp_query;         $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';          $class_names = $value = '';          $classes = empty( $item->classes ) ? array() : (array) $item->classes;         $classes[] = 'menu-item-' . $item->id;          $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );         $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';          $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->id, $item, $args );         $id = $id ? ' id="' . esc_attr( $id ) . '"' : '';          $output .= $indent . '<li' . $id . $value . $class_names .'>';          $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';         $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';         $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';          //add php here determine whatever need link         if ( ! empty ( $_server['query_string'] ) ) {             $addedstuff = '?ref=' . substr( $_server['query_string'], 4 );             }else {                      $addedstuff = '?ref=mhammonds'; }         $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url.$addedstuff) .'"' : '';         ////////////////////          $item_output = $args->before;         $item_output .= '<a'. $attributes .'>';         $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->id ) . $args->link_after;         $item_output .= '</a>';         $item_output .= $args->after;          $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );     } } 

and added walker 'new query_nav' nav-menu-template.php:

function wp_nav_menu( $args = array() ) {     static $menu_id_slugs = array();      $defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'menu_id' => '',     'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',     'depth' => 0, 'walker' => 'new query_nav()', 'theme_location' => '' ); 

i informed warning class 'new query_nav()' not found on line 660, added so:

function walk_nav_menu_tree( $items, $depth, $r ) {     $walker = ( empty($r->walker) ) ? new walker_nav_menu : $r->walker;     $args = array( $items, $depth, $r );      return call_user_func_array( array( $walker, 'walk', 'new query_nav()'), $args ); 

now have warning stating:

call_user_func_array() expects parameter 1 valid callback, array must have 2 members in /home/ballaboy258/public_html/wp-includes/nav-menu-template.php on line 660 

i have removed each 1 , neither has solved problem. if remove $walker, 'walk' not found. if remove 'walk', 'new query_nav()' not found. if remove 'new query_nav()', again, "new query_nav()' not found. doesn't make sense. did miss step, or syntax wrong? i'm confused , can't find on web me.

it means callback array

array( $walker, 'walk', 'new query_nav()'),  

should comprise 2 elements

  • a class
  • a method

that represent function calling

you have provided three


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -