public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { $control_buffy = ''; //read the menu setting from post meta (menu id, key, single) $td_mega_menu_cat = get_post_meta($item->ID, 'td_mega_menu_cat', true); $td_mega_menu_page_id = get_post_meta($item->ID, 'td_mega_menu_page_id', true); //make the tree $td_category_tree = array_merge(array(' - 不是大菜单 - ' => ''), td_util::get_category2id_array(false)); //make a new ui control ( dropdown ) $control_buffy .= '<p class="description description-wide"><br><br>'; $control_buffy .= '<label>'; $control_buffy .= '使这个分类为大菜单'; $control_buffy .= '</label>'; $control_buffy .= '<select name="td_mega_menu_cat[' . $item->ID . ']" id="" class="widefat code edit-menu-item-url">'; foreach ($td_category_tree as $category => $category_id) { $control_buffy .= '<option value="' . $category_id . '"' . selected($td_mega_menu_cat, $category_id, false) . '>' . $category . '</option>'; } $control_buffy .= ' </select>'; $control_buffy .= '</p>'; $control_buffy .= '<br>或<br>'; //make a new ui control ( dropdown ) $control_buffy .= '<p class="description description-wide">'; $control_buffy .= '<label>'; $control_buffy .= '在菜单加载页面(输入页面ID)'; $control_buffy .= '</label><br>'; $control_buffy .= '<input name="td_mega_menu_page_id[' . $item->ID . ']" type="text" value="' . $td_mega_menu_page_id . '" />'; $control_buffy .= '<span class="td-wpa-info"><strong>提示:</strong>如果你选择加载一个大菜单或页面,请不要给此项目添加子菜单。大菜单和大页面菜单是顶级菜单项目。<a href="http://forum.tagdiv.com/menus-newsmag/" target="_blank">阅读更多</a></span>'; $control_buffy .= '</p>'; //run the parent and add in $buffy (byref) our code via regex $buffy = ''; parent::start_el($buffy, $item, $depth, $args, $id); $buffy = preg_replace('/(?=<div.*submitbox)/', $control_buffy, $buffy); $output .= $buffy; }
function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { $tmp_output = ''; parent::start_el($tmp_output, $item, $depth, $args, $id); $this->vw_insert_custom_fields($tmp_output, $item, $depth); $output .= $tmp_output; }
public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { // get current menu id if (!$this->current_menu) { $menu = wp_get_post_terms($item->ID, 'nav_menu'); if (!empty($menu[0])) { $this->current_menu = $menu[0]->term_id; } if (!$this->current_menu && $_REQUEST['menu']) { $this->current_menu = $_REQUEST['menu']; } } $item_output = ''; parent::start_el($item_output, $item, $depth, $args, $id); // add new fields before <div class="menu-item-actions description-wide submitbox"> $fields = $this->get_custom_fields($item, $depth); // nav menu hook support decided by the community of plugin authors ob_start(); do_action('wp_nav_menu_item_custom_fields', $item->ID, $item, $depth, $args); $fields .= ob_get_clean(); if ($fields) { $item_output = preg_replace('/(?=<div[^>]+class="[^"]*submitbox)/', $fields, $item_output); } $output .= $item_output; }
public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { $control_buffy = ''; //read the menu setting from post meta (menu id, key, single) $td_mega_menu_cat = get_post_meta($item->ID, 'td_mega_menu_cat', true); $td_mega_menu_page_id = get_post_meta($item->ID, 'td_mega_menu_page_id', true); //make the tree $td_category_tree = array_merge(array(' - Not mega menu - ' => ''), td_util::get_category2id_array(false)); //make a new ui control ( dropdown ) $control_buffy .= '<p class="description description-wide"><br><br>'; $control_buffy .= '<label>'; $control_buffy .= 'Make this a category mega menu'; $control_buffy .= '</label>'; $control_buffy .= '<select name="td_mega_menu_cat[' . $item->ID . ']" id="" class="widefat code edit-menu-item-url">'; foreach ($td_category_tree as $category => $category_id) { $control_buffy .= '<option value="' . $category_id . '"' . selected($td_mega_menu_cat, $category_id, false) . '>' . $category . '</option>'; } $control_buffy .= ' </select>'; $control_buffy .= '</p>'; $control_buffy .= '<br>OR<br>'; //make a new ui control ( dropdown ) $control_buffy .= '<p class="description description-wide">'; $control_buffy .= '<label>'; $control_buffy .= 'Load a page in the menu (enter the page ID)'; $control_buffy .= '</label><br>'; $control_buffy .= '<input name="td_mega_menu_page_id[' . $item->ID . ']" type="text" value="' . $td_mega_menu_page_id . '" />'; $control_buffy .= '<span class="td-wpa-info"><strong>Just a tip:</strong> If you choose to load a mega menu or a page, please do not add submenus to this item. The mega menu and mega page menu have to be the top most menu item. <a href="http://forum.tagdiv.com/menus-newsmag/" target="_blank">Read more</a></span>'; $control_buffy .= '</p>'; //run the parent and add in $buffy (byref) our code via regex $buffy = ''; parent::start_el($buffy, $item, $depth, $args, $id); $buffy = preg_replace('/(?=<div.*submitbox)/', $control_buffy, $buffy); $output .= $buffy; }
function start_el(&$output, $object, $depth = 0, $args = array(), $current_object_id = 0) { // append next menu element to $output parent::start_el($output, $object, $depth, $args, $current_object_id); // now let's add a custom form field if (!class_exists('phpQuery')) { // load phpQuery at the last moment, to minimise chance of conflicts (ok, it's probably a bit too defensive) require_once 'phpQuery-onefile.php'; } $_doc = phpQuery::newDocumentHTML($output); $_li = phpQuery::pq('li.menu-item:last'); // ":last" is important, because $output will contain all the menu elements before current element // if the last <li>'s id attribute doesn't match $item->ID something is very wrong, don't do anything // just a safety, should never happen... $menu_item_id = str_replace('menu-item-', '', $_li->attr('id')); if ($menu_item_id != $object->ID) { return; } // fetch previously saved meta for the post (menu_item is just a post type) $curr_bg = esc_attr(get_post_meta($menu_item_id, 'snpshpwp_menu_item_bg', TRUE)); $curr_bg_pos = esc_attr(get_post_meta($menu_item_id, 'snpshpwp_menu_item_bg_pos', TRUE)); $curr_upldr = '<span class="button media_upload_button" id="snpshpwp_upload_' . $menu_item_id . '">' . __('Upload', 'snpshpwp') . '</span>'; // by means of phpQuery magic, inject a new input field $_li->find('a.item-delete')->before("\n\t\t\t\t\t<p class='snpshpwp_menu_item_bg description description-thin'>\n\t\t\t\t\t<label for='snpshpwp_menu_item_bg_{$menu_item_id}'>" . __('Background image', 'snpshpwp') . "<br/>\n\t\t\t\t\t<input type='text' value='{$curr_bg}' name='snpshpwp_menu_item_bg_{$menu_item_id}' /><br/>\n\t\t\t\t\t</label>\n\t\t\t\t\t{$curr_upldr}\n\t\t\t\t\t</p>\n\t\t\t\t\t<p class='snpshpwp_menu_item_bg_pos description description-thin'>\n\t\t\t\t\t<label for='snpshpwp_menu_item_bg_{$menu_item_id}'>" . __('Background orientation', 'snpshpwp') . "<br/>\n\t\t\t\t\t<select name='snpshpwp_menu_item_bg_pos_{$menu_item_id}'>\n\t\t\t\t\t\t<option value='left-landscape'" . ($curr_bg_pos == 'left-landscape' ? ' selected' : '') . ">" . __('Left Landscape', 'snpshpwp') . "</option>\n\t\t\t\t\t\t<option value='left-portraid'" . ($curr_bg_pos == 'left-portraid' ? ' selected' : '') . ">" . __('Left Portraid', 'snpshpwp') . "</option>\n\t\t\t\t\t\t<option value='right-landscape'" . ($curr_bg_pos == 'right-landscape' ? ' selected' : '') . ">" . __('Right Landscape', 'snpshpwp') . "</option>\n\t\t\t\t\t\t<option value='right-portraid'" . ($curr_bg_pos == 'right-portraid' ? ' selected' : '') . ">" . __('Right Portraid', 'snpshpwp') . "</option>\n\t\t\t\t\t\t<option value='pattern-repeat'" . ($curr_bg_pos == 'pattern-repeat' ? ' selected' : '') . ">" . __('Pattern', 'snpshpwp') . "</option>\n\t\t\t\t\t\t<option value='framed-full'" . ($curr_bg_pos == 'framed-full' ? ' selected' : '') . ">" . __('Framed', 'snpshpwp') . "</option>\n\t\t\t\t\t</select>\n\t\t\t\t\t</label>\n\t\t\t\t\t</p>\n\t\t\t\t\t"); // swap the $output $output = $_doc->html(); }
/** * Override the start of elements in the walker. * * @param string $output * @param object $item * @param int $depth * @param array $args * @param int $id */ function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { $item_output = ''; parent::start_el($item_output, $item, $depth, $args); $new_fields = $this->field_display($item->ID, array('args' => $args, 'depth' => $depth, 'item' => $item, 'item_output' => $item_output)); $item_output = preg_replace('/(?=<p[^>]+class="[^"]*field-move)/', $new_fields, $item_output); $output .= $item_output; }
/** * Start the element output. * * We're injecting our custom fields after the div.submitbox * * @see Walker_Nav_Menu::start_el() * @since 0.1.0 * * @param string $output Passed by reference. Used to append additional content. * @param object $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. * @param array $args Menu item args. * @param int $id Nav menu ID. */ function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { $item_output = ''; parent::start_el($item_output, $item, $depth, $args, $id); $position = '<p class="field-move'; $extra = $this->get_fields($item, $depth, $args, $id); $output .= str_replace($position, $extra . $position, $item_output); }
function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { $desc_snipp = '<div class="menu-item-actions description-wide submitbox">'; parent::start_el($output, $item, $depth, $args, $id); $pos = strrpos($output, $desc_snipp); if ($pos !== false && 'taxonomy' == $item->type) { $output = substr_replace($output, milkit_edit_menu_item_settings($item) . $desc_snipp, $pos, strlen($desc_snipp)); } }
function start_el(&$output, $item, $depth, $args) { $item_output = ''; parent::start_el($item_output, $item, $depth, $args); if ($new_fields = kcSettings_menu_item::get_fields($item, $depth, $args)) { $item_output = preg_replace('/(?=<div[^>]+class="[^"]*submitbox)/', $new_fields, $item_output); } $output .= $item_output; }
function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { parent::start_el($output, $item, $depth, $args, $id); // Input the option right before Submit Button $desc_snipp = '<div class="menu-item-actions description-wide submitbox">'; $pos = strrpos($output, $desc_snipp); if ($pos !== false) { $output = substr_replace($output, $this->mega_menu_setting($item, $depth) . $desc_snipp, $pos, strlen($desc_snipp)); } }
function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { $item_output = ''; parent::start_el($item_output, $item, $depth, $args); // inject $new_fields before: <div class="menu-item-actions description-wide submitbox"> if ($new_fields = Willow_Custom_Menu::instance()->render_fields($item, $depth, $args)) { $item_output = preg_replace('/(?=<div[^>]+class="[^"]*submitbox)/', $new_fields, $item_output); } $output .= $item_output; }
/** * Start the element output. * * @param string $output Passed by reference. Used to append additional content. * @param object $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. * @param array $args An array of arguments. @see wp_nav_menu() * @param int $id Current item ID. */ public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { parent::start_el($output, $item, $depth, $args, $id); $flag = '<!--CarbonFields-->'; ob_start(); do_action('crb_print_carbon_container_nav_menu_fields_html', $item, $output, $depth, $args, $id); echo esc_attr($flag); $fields = ob_get_clean(); $marker = '<p class="field-move hide-if-no-js description description-wide">'; $output = preg_replace('~(?<!' . preg_quote($flag, '~') . ')' . preg_quote($marker, '~') . '~', $fields . $marker, $output); }
function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { // append next menu element to $output parent::start_el($output, $item, $depth, $args); // now let's add the megamenu layout select box but only for the first level if ($depth == 0 && ($item->object == 'category' || $item->object == 'post_format')) { set_time_limit(0); //load up the library if (!function_exists('bw_str_get_dom')) { require_once BW_FRAME_LIB . 'ganon/ganon.php'; } // Create DOM from string $_doc = bw_str_get_dom($output); $_li = $_doc->select('.menu-item-depth-0', -1); // "-1" aka the last element is important, because $output will contain all the menu elements before current element // if the last <li>'s id attribute doesn't match $item->ID something is very wrong, don't do anything // just a safety, should never happen... $menu_item_id = str_replace('menu-item-', '', $_li->getAttribute('id')); if ($menu_item_id != $item->ID) { return; } //somewhere to save the new HTML code $newHtml = ''; // fetch previously saved meta for the post (menu_item is just a post type) $current_val = esc_attr(get_post_meta($item->ID, 'bw_megamenu_layout', TRUE)); //let's make the HTML //go through the options values and titles $supermenu_layout = array('default' => __('Default', BW_THEME), 'latest_posts' => __('Latest Posts', BW_THEME), 'slider_latest_posts' => __('Slider + Latest Posts', BW_THEME)); if (!empty($supermenu_layout)) { $newHtml .= '<p class="link-to-original bw_custom_menu_meta"><label>' . __('Select MegaMenu Layout:', BW_THEME) . ' <select name="bw_megamenu_layout_' . $menu_item_id . '">'; foreach ($supermenu_layout as $key => $value) { $selected = ''; if ($key == $current_val) { $selected = 'selected'; } $newHtml .= '<option value="' . $key . '" ' . $selected . '>' . $value . '</option>'; } $newHtml .= '</select></label></p>'; } // inject the new input field $whereto = $_li->select('.menu-item-actions', 0); //add it before $whereto->setInnerText($newHtml . $whereto->getInnerText()); // swap the $output $output = $_doc->getInnerText(); //cleanup //$_doc->__destruct(); unset($_doc); } }
/** * @see Walker_Nav_Menu_Edit::start_el() * @since 1.0 * @access public * * @global $wp_version * @uses Walker_Nav_Menu_Edit::start_el() * @uses admin_url() To get URL of uploader. * @uses esc_url() To escape URL. * @uses add_query_arg() To append variables to URL. * @uses esc_attr() To escape string. * @uses has_post_thumbnail() To check if item has thumb. * @uses get_the_post_thumbnail() To get item's thumb. * @uses version_compare() To compare WordPress versions. * @uses wp_create_nonce() To create item's nonce. * @uses esc_html__() To translate & escape string. * @uses esc_html() To escape string. * @uses do_action_ref_array() Calls 'nmi_menu_item_walker_output' with the output. * post object, depth and arguments to overwrite item's output. * @uses NMI_Walker_Nav_Menu_Edit::get_settings() To get JSONed item's data. * @uses do_action_ref_array() Calls 'nmi_menu_item_walker_end' with the output. * post object, depth and arguments to overwrite item's output. * * @param string $output Passed by reference. Used to append additional content. * @param object $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. * @param object $args */ public function start_el(&$output, $item, $depth, $args) { global $wp_version; // First, make item with standard class parent::start_el($output, $item, $depth, $args); // Now add additional content $item_id = $item->ID; // Form upload link $upload_url = admin_url('media-upload.php'); $query_args = array('post_id' => $item_id, 'tab' => 'gallery', 'TB_iframe' => '1', 'width' => '640', 'height' => '425'); $upload_url = esc_url(add_query_arg($query_args, $upload_url)); // Hidden field with item's ID $output .= '<input type="hidden" name="nmi_item_id" id="nmi_item_id" value="' . esc_attr($item_id) . '" />'; // Generate menu item image & link's text string if (has_post_thumbnail($item_id)) { $post_thumbnail = get_the_post_thumbnail($item_id, 'thumb'); $output .= '<div class="nmi-current-image nmi-div" style="display: none;"><a href="' . $upload_url . '" data-id="' . $item_id . '" class="thickbox add_media">' . $post_thumbnail . '</a></div>'; $link_text = __('Change menu item image', 'nmi'); // For WP 3.5+, add 'remove' action link if (version_compare($wp_version, '3.5', '>=')) { $ajax_nonce = wp_create_nonce('set_post_thumbnail-' . $item_id); $remove_link = ' | <a href="#" data-id="' . $item_id . '" class="nmi_remove" onclick="NMIRemoveThumbnail(\'' . $ajax_nonce . '\',' . $item_id . ');return false;">' . esc_html__('Remove menu item image', 'nmi') . '</a>'; } } else { $output .= '<div class="nmi-current-image nmi-div" style="display: none;"></div>'; $link_text = __('Upload menu item image', 'nmi'); } // Append menu item upload link $output .= '<div class="nmi-upload-link nmi-div" style="display: none;"><a href="' . $upload_url . '" data-id="' . $item_id . '" class="thickbox add_media">' . esc_html($link_text) . '</a>'; // Append menu item 'remove' link if (isset($remove_link)) { $output .= $remove_link; } // Close menu item $output .= '</div>'; // Filter output do_action_ref_array('nmi_menu_item_walker_output', array(&$output, $item, $depth, $args)); // Add JSONed meta data $output .= $this->get_settings($item_id); do_action_ref_array('nmi_menu_item_walker_end', array(&$output, $item, $depth, $args)); }
public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { $temp_output = ''; $mega_menu_html = ''; if ($item->object == 'category') { $mega_menu_html .= '<p class="field-custom description description-wide"> <label for="edit-menu-item-mega-' . $item->db_id . '"> <input type="checkbox" id="edit-menu-item-mega-' . $item->db_id . '" class="widefat code edit-menu-item-custom" name="menu-item-mega-menu-cat[' . $item->db_id . ']" value="1" ' . checked($item->mega_menu_cat, 1, false) . ' /> ' . __('Mega Menu (display posts from category)', THEME_SLUG) . '</label> </p>'; } else { $mega_menu_html .= '<p class="field-custom description description-wide"> <label for="edit-menu-item-mega-' . $item->db_id . '"> <input type="checkbox" id="edit-menu-item-mega-' . $item->db_id . '" class="widefat code edit-menu-item-custom" name="menu-item-mega-menu[' . $item->db_id . ']" value="1" ' . checked($item->mega_menu, 1, false) . ' /> ' . __('Mega Menu (classic)', THEME_SLUG) . ' </label></p>'; } parent::start_el($temp_output, $item, $depth, $args, $id); $temp_output = preg_replace('/(?=<div.*submitbox)/', $mega_menu_html, $temp_output); $output .= $temp_output; }
public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { $buffer = $output; parent::start_el($output, $item, $depth, $args, $id); $options = apply_filters("pe_theme_menu_custom_fields", false, $depth, $item, $args, $id); $li = str_replace($buffer, "", $output); $item_id = esc_attr($item->ID); $fields = ""; $values = maybe_unserialize(get_post_meta($item_id, PE_THEME_META, true)); foreach ($options as $name => $data) { $optionClass = "PeThemeFormElement{$data['type']}"; if (isset($values[$name])) { $data["value"] = $values[$name]; } $field = new $optionClass(PE_THEME_META . "[{$item_id}]", $name, $data); //$item->registerAssets(); $fields .= $field->get_render(); } $fields = sprintf('<div class="pe_theme"><div class="contents">%s</div></div>', $fields); $li = preg_replace('/(<div class="menu-item-settings" .+>)/', '\\1' . $fields, $li); $output = $buffer . $li; }
public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { $buffy = ''; $control_buffy = ''; //read the menu setting $td_mega_menu_cat = get_post_meta($item->ID, 'td_mega_menu_cat', true); //make the tree $td_category_tree = array_merge(array(' - Not mega menu - ' => ''), td_util::get_category2id_array(false)); $control_buffy .= '<p class="description description-wide">'; $control_buffy .= '<label>'; $control_buffy .= 'Make this a category mega menu'; $control_buffy .= '</label>'; $control_buffy .= '<select name="td_mega_menu_cat[' . $item->ID . ']" id="" class="widefat code edit-menu-item-url">'; foreach ($td_category_tree as $category => $category_id) { $control_buffy .= '<option value="' . $category_id . '"' . selected($td_mega_menu_cat, $category_id, false) . '>' . $category . '</option>'; } $control_buffy .= ' </select>'; $control_buffy .= '</p>'; parent::start_el($buffy, $item, $depth, $args, $id); $buffy = preg_replace('/(?=<div.*submitbox)/', $control_buffy, $buffy); $output .= $buffy; }
function start_el(&$output, $object, $depth = 0, $args = array(), $current_object_id = 0) { $item_output = ''; parent::start_el($item_output, $object, $depth, $args, $current_object_id); $new_fields = apply_filters('nav_menu_item_additional_fields', '', $item_output, $object, $depth, $args, $current_object_id); // Inject $new_fields before: <div class="menu-item-actions description-wide submitbox"> if ($new_fields) { $item_output = preg_replace('/(?=<p[^>]+class="[^"]*field-move)/', $new_fields, $item_output); } $output .= $item_output; }
function start_el(&$output, $item, $depth, $args) { $item_output = ''; parent::start_el($item_output, $item, $depth, $args); $new_fields = apply_filters('xteam_nav_menu_item_additional_fields', '', $item_output, $item, $depth, $args); // Inject $new_fields before: <div class="menu-item-actions description-wide submitbox"> if ($new_fields) { $item_output = preg_replace('/(?=<div[^>]+class="[^"]*submitbox)/', $new_fields, $item_output); } $output .= $item_output; }
function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { $item_output = ''; parent::start_el($item_output, $item, $depth, $args, $id); $output .= preg_replace('/(?=<p[^>]+class="[^"]*field-move)/', em_MenuMeta_Engine::getInstance()->generate_field($item, $depth, $args), $item_output); }
/** * @see Walker::start_el() * @since 3.0.0 * * @param string $output Passed by reference. Used to append additional content. * @param object $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. * @param object $args */ function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { parent::start_el($output, $item, $depth, $args, $id); $item_id = esc_attr($item->ID); $to_add = ''; $icon_opts = ''; foreach (kleo_icons_array() as $icon) { $selected_icon = $item->icon == $icon ? ' selected="selected"' : ''; $icon_opts .= '<option value="' . $icon . '"' . $selected_icon . '>' . $icon . '</option> '; } $to_add .= '<p class="menu-item-icons">' . '<label for="edit-menu-item-icons-' . $item_id . '">' . __('Choose icon', 'kleo_framework') . ' <select id="edit-menu-item-icon-' . $item_id . '" name="menu-item-icon[' . $item_id . ']">' . $icon_opts . '</select>' . ' <select id="edit-menu-item-iconpos-' . $item_id . '" name="menu-item-iconpos[' . $item_id . ']">' . '<option value="">' . __('Before title', 'kleo_framework') . '</option>' . '<option' . ($item->iconpos == 'after' ? ' selected="selected"' : '') . ' value="after">' . __('After title', 'kleo_framework') . '</option>' . '<option ' . ($item->iconpos == 'icon' ? ' selected="selected"' : '') . ' value="icon">' . __('Just the icon', 'kleo_framework') . '</option>' . '</select>' . '</label>' . '</p>'; if ($depth == 0) { $to_add .= '<p class="menu-item-mega"> <label for="edit-menu-item-mega-' . $item_id . '"> <input type="checkbox" id="edit-menu-item-mega-' . $item_id . '" value="yes" name="menu-item-mega[' . $item_id . ']"' . ($item->mega == 'yes' ? 'checked="checked"' : '') . ' />' . __('Enable Mega Menu for child items.', 'kleo_framework') . '</label> </p>'; } ob_start(); // action for other plugins do_action('wp_nav_menu_item_custom_fields', $item_id, $item, $depth, $args); $to_add .= ob_get_clean(); $output = str_replace('<label for="edit-menu-item-target-' . $item_id . '">', '</p>' . $to_add . '<p class="field-link-target description"><label for="edit-menu-item-target-' . $item_id . '">', $output); }
/** * @see Walker_Nav_Menu_Edit::start_el() * @since 1.0 * @access public * * @global $wp_version * @uses Walker_Nav_Menu_Edit::start_el() * @uses admin_url() To get URL of uploader. * @uses esc_url() To escape URL. * @uses add_query_arg() To append variables to URL. * @uses esc_attr() To escape string. * @uses has_post_thumbnail() To check if item has thumb. * @uses get_the_post_thumbnail() To get item's thumb. * @uses version_compare() To compare WordPress versions. * @uses wp_create_nonce() To create item's nonce. * @uses esc_html__() To translate & escape string. * @uses esc_html() To escape string. * @uses do_action_ref_array() Calls 'nmi_menu_item_walker_output' with the output. * post object, depth and arguments to overwrite item's output. * @uses NMI_Walker_Nav_Menu_Edit::get_settings() To get JSONed item's data. * @uses do_action_ref_array() Calls 'nmi_menu_item_walker_end' with the output. * post object, depth and arguments to overwrite item's output. * * @param string $output Passed by reference. Used to append additional content. * @param object $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. * @param array $args Not used. * @param int $id Not used. */ public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { global $wp_version; // First, make item with standard class parent::start_el($output, $item, $depth, $args, $id); // Now add additional content $item_id = $item->ID; // Form upload link $upload_url = admin_url('media-upload.php'); $query_args = array('post_id' => $item_id, 'tab' => 'gallery', 'TB_iframe' => '1', 'width' => '640', 'height' => '425'); $upload_url = esc_url(add_query_arg($query_args, $upload_url)); // Hidden field with item's ID $output .= '<input type="hidden" name="nmi_item_id" id="nmi_item_id" value="' . esc_attr($item_id) . '" />'; // Append menu item upload link $output .= '<div class="nmi-upload-link nmi-div" style="display: none;">'; $anchor = get_post_meta($item_id, '_menu-item-anchor', true); $output .= ' <p class="description description-wide"> <label> Anchor<br> <input type="text" name="menu-item-anchor[' . $item_id . ']" value="' . $anchor . '" class="widefat" /> </label> </p><div style="clear:both;"></div>'; // Generate menu item image & link's text string if (has_post_thumbnail($item_id)) { $post_thumbnail = get_the_post_thumbnail($item_id, 'thumb'); $output .= '<div class="nmi-current-image nmi-div" style="display: none;"><a href="' . $upload_url . '" data-id="' . $item_id . '" class="thickbox add_media">' . $post_thumbnail . '</a></div>'; $link_text = __('Change menu item image', 'nmi'); // For WP 3.5+, add 'remove' action link if (version_compare($wp_version, '3.5', '>=')) { $ajax_nonce = wp_create_nonce('set_post_thumbnail-' . $item_id); $remove_link = ' | <a href="#" data-id="' . $item_id . '" class="nmi_remove" onclick="NMIRemoveThumbnail(\'' . $ajax_nonce . '\',' . $item_id . ');return false;">' . esc_html__('Remove menu item image', 'nmi') . '</a>'; } } else { $output .= '<div class="nmi-current-image nmi-div" style="display: none;"></div>'; $link_text = __('Upload menu item image', 'nmi'); } // Append menu item upload link $output .= '<a href="' . $upload_url . '" data-id="' . $item_id . '" class="thickbox add_media">' . esc_html($link_text) . '</a>'; // Append menu item 'remove' link if (isset($remove_link)) { $output .= $remove_link; } $bg_position = get_post_meta($item_id, '_menu-item-background_position', true); $bg_repeat = get_post_meta($item_id, '_menu-item-background_repeat', true); $output .= ' <br><br> <div class="clear"></div> <select name="menu-item-background_repeat[' . $item_id . ']" id="background_img-repeat" class="option-tree-ui-select "> <option value="">background-repeat</option> <option value="no-repeat" ' . selected('no-repeat', $bg_repeat, false) . '>No Repeat</option> <option value="repeat" ' . selected('repeat', $bg_repeat, false) . '>Repeat All</option> <option value="repeat-x" ' . selected('repeat-x', $bg_repeat, false) . '>Repeat Horizontally</option> <option value="repeat-y" ' . selected('repeat-y', $bg_repeat, false) . '>Repeat Vertically</option> <option value="inherit" ' . selected('inherit', $bg_repeat, false) . '>Inherit</option> </select> <select name="menu-item-background_position[' . $item_id . ']" id="background_img-position" class="option-tree-ui-select "> <option value="">background-position</option> <option value="left top" ' . selected('left top', $bg_position, false) . '>Left Top</option> <option value="left center" ' . selected('left center', $bg_position, false) . '>Left Center</option> <option value="left bottom" ' . selected('left bottom', $bg_position, false) . '>Left Bottom</option> <option value="center top" ' . selected('center top', $bg_position, false) . '>Center Top</option> <option value="center center" ' . selected('center center', $bg_position, false) . '>Center Center</option> <option value="center bottom" ' . selected('center bottom', $bg_position, false) . '>Center Bottom</option> <option value="right top" ' . selected('right top', $bg_position, false) . '>Right Top</option> <option value="right center" ' . selected('right center', $bg_position, false) . '>Right Center</option> <option value="right bottom" ' . selected('right bottom', $bg_position, false) . '>Right Bottom</option> </select> <br><br> <div class="clear"></div> '; // Close menu item $output .= '</div>'; // Filter output do_action_ref_array('nmi_menu_item_walker_output', array(&$output, $item, $depth, $args)); // Add JSONed meta data $output .= $this->get_settings($item_id); do_action_ref_array('nmi_menu_item_walker_end', array(&$output, $item, $depth, $args)); }
/** * Start the element output. * * @see Walker_Nav_Menu::start_el() * @since 1.0.0 * * @param string $output Passed by reference. Used to append additional content. * @param object $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. * @param array $args Not used. * @param int $id Not used. */ public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { $item_output = ''; parent::start_el($item_output, $item, $depth, $args); $output .= preg_replace('/(?=<p[^>]+class="[^"]*field-move)/', $this->get_fields($item, $depth, $args), $item_output); }
/** * @see Walker::start_el() * @since 3.0.0 * * @param string $output Passed by reference. Used to append additional content. * @param object $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. * @param object $args */ function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { parent::start_el($output, $item, $depth, $args, $id); $item_id = esc_attr($item->ID); $to_add = '<p class="menu-item-mega"> <label for="edit-menu-item-mega-' . $item_id . '"> <input type="checkbox" id="edit-menu-item-mega-' . $item_id . '" value="yes" name="menu-item-mega[' . $item_id . ']"' . ($item->mega == 'yes' ? 'checked="checked"' : '') . ' />' . __('Enable Mega Menu for child items.', 'kleo_framework') . '</label> </p>'; if ($depth !== 0) { $to_add = ''; } $output = str_replace('<label for="edit-menu-item-target-' . $item_id . '">', '</p>' . $to_add . '<p class="field-link-target description"><label for="edit-menu-item-target-' . $item_id . '">', $output); }