Woocommerce - extend product search form - woocommerce

I need to extend the functionality of product search form to be able to search for products by SKU. This searches only in the title and content. Have no idea.
<?php
if ( isset( $_REQUEST['product_cat'] ) && ! empty( $_REQUEST['product_cat'] ) ) {
$optsetlect = $_REQUEST['product_cat'];
} else {
$optsetlect = 0;
}
$args = array(
'show_option_all' => __( 'All categories', 'domain' ),
'hierarchical' => 1,
'hide_empty' => 0,
'class' => 'cat',
'echo' => 0,
'value_field' => 'slug',
'selected' => $optsetlect
);
$args['taxonomy'] = 'product_cat';
$args['name'] = 'product_cat';
$args['class'] = 'selectpicker dropdown-select';
?>
<form role="search" method="get" action="<?php echo esc_url( home_url() ); ?>">
<input type="hidden" name="post_type" value="product">
<div class="input-group">
<input id="woocommerce-product-search-field-<?php echo isset( $index ) ? absint( $index ) : 0; ?>" name="s" placeholder="Search products" type="text" autocomplete="off">
<div class="input-group-append">
<?php echo wp_dropdown_categories( $args ); ?>
<button class="btn btn-primary" type="submit">
<span class="ec ec-search"></span>
</button>
</div>
</div>
</form>

You should try something like that:
add_filter( 'get_product_search_form' , 'woo_custom_product_searchform' );
function woo_custom_product_searchform( $form ) {
$form = '<form role="search" method="get" id="searchform" action="' . esc_url( home_url( '/' ) ) . '">
<div>
<label class="screen-reader-text" for="s">' . __( 'Search for:', 'woocommerce' ) . '</label>
<input type="text" value="' . get_search_query() . '" name="s" id="s" placeholder="' . __( 'My Search form', 'woocommerce' ) . '" />
<input type="submit" id="searchsubmit" value="'. esc_attr__( 'Search', 'woocommerce' ) .'" />
<input type="hidden" name="post_type" value="product" />
</div>
</form>';
return $form;
}

Related

Data insert from front-end duplicate data can't protected in WordPress

At first, I created a custom template and wrote the following script.
I was trying to protect duplicate values using isset but didn't get the solution and logic working. Can you tell me how to fix it?
if ( isset( $_POST['submit'] ) ) {
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && ! empty( $_POST['action'] ) ) {
if ( isset( $_POST['title'] ) ) {
$title = $_POST['title'];
} else {
echo 'Please enter a title';
}
if ( isset( $_POST['description'] ) ) {
$description = $_POST['description'];
} else {
echo 'Please enter the content';
}
$post = array(
'post_title' => $title,
'post_content' => $description,
'post_status' => 'draft',
'post_type' => 'portfolio',
);
$pid = wp_insert_post( $post );
}
}
?>
<form action="" method="post">
<p>
<label for="title">Titolo</label><br />
<input type="text" id="title" value="" tabindex="1" size="20" name="title" />
</p>
<p>
<label for="description">Testo</label><br />
<textarea id="description" tabindex="3" name="description" cols="50" rows="6"></textarea>
</p>
<p align="right">
<input type="submit" value="submit" id="submit" name="submit"/>
</p>
<input type="hidden" name="post_type" id="post_type" value="domande" />
<input type="hidden" name="action" value="post" />
<?php wp_nonce_field( 'new-post' ); ?>
</form>

WordPress Comment Form redirecting to another post's comment

Here is the code I used:
The code snippet is as follows -
I used custom markup for comment form fields and when I submit the form it takes me to another post's comment. What can be issue in this code ?
$fields = array(
'author' => ' <div class="form-group col-md-4">' . ' <input type="text" class="form-control" id="name" name="name" placeholder="Name" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . ' ></div>',
'email' => ' <div class="form-group col-md-4">' . ' <input type="email" class="form-control" id="email" name="email" placeholder="Email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size ="30" ' . ' ></div>',
);
$comments_args = array(
'fields' => $fields,
'comment_field' => ' <div class="form-group col-12">
<textarea class="form-control" id="comment" name="comment" placeholder="Comment"></textarea>
</div>
<!-- Single Form End -->
',
'class_form' => 'from_main row',
'title_reply_before' => '',
'title_reply_after' => '',
'label_submit' => 'Submit',
'submit_button' => '
Submit',
);
if ( comments_open() || pings_open() ) {
if ( $comments ) {
echo '<hr class="styled-separator is-style-wide" aria-hidden="true" />';
}
comment_form( $comments_args );
if ( $comments ) {
echo '<hr class="styled-separator is-style-wide" aria-hidden="true" />';
}
} elseif ( is_single() ) {
if ( $comments ) {
echo '<hr class="styled-separator is-style-wide" aria-hidden="true" />';
}
?>
Thanks!

Give error if checkbox isn't selected on Woocommerce Account registration

I'm trying to add some custom fields in the Woocommerce User account registration form.
I've succesfully added First Name and last name, nut i'm trying to add a T&C agreement checkbox, that if it isn't selected it doesn't let the user continue the registration.
I've managed to display it correctly the i cannot make the validation work.
What am i doing wrong?
PS. just to know, is it possibile to make these checks live, without needing to reload the page?
Thanks
The code i've used:
add_action( 'woocommerce_register_form_start', 'cbi_custom_woo_account_registration' );
function cbi_custom_woo_account_registration() {
?>
<p class="woocommerce-FormRow woocommerce-FormRow--wide form-row form-row-wide first">
<label for="reg_billing_first_name"><?php _e( 'First name', 'custom-cbi-parts' ); ?> <span class="required">*</span></label>
<input type="text" class="woocommerce-Input woocommerce-Input--text input-text form-control" name="billing_first_name" id="reg_billing_first_name" value="<?php if ( ! empty( $_POST['billing_first_name'] ) ) esc_attr_e( $_POST['billing_first_name'] ); ?>" />
</p>
<p class="woocommerce-FormRow woocommerce-FormRow--wide form-row form-row-wide">
<label for="reg_billing_last_name"><?php _e( 'Last name', 'custom-cbi-parts' ); ?> <span class="required">*</span></label>
<input type="text" class="woocommerce-Input woocommerce-Input--text input-text form-control" name="billing_last_name" id="reg_billing_last_name" value="<?php if ( ! empty( $_POST['billing_last_name'] ) ) esc_attr_e( $_POST['billing_last_name'] ); ?>" />
</p>
<p class="woocommerce-FormRow woocommerce-FormRow--wide form-row form-row-wide">
<label for="accept_terms"><?php _e( 'I agree TeC', 'custom-cbi-parts' ); ?> <span class="required">*</span></label>
<input type="checkbox" class="woocommerce-Input woocommerce-Input--text input-text form-control" name="accept_terms" id="accept_terms" value="<?php if ( ! empty( $_POST['accept_terms'] ) ) esc_attr_e( $_POST['accept_terms'] ); ?>" />
</p>
<div class="clear"></div>
<?php
}
// 2. VALIDATE FIELDS
add_filter( 'woocommerce_registration_errors', 'cbi_validate_custom_reg_fields', 10, 3 );
function cbi_validate_custom_reg_fields( $errors, $username, $email ) {
if ( isset( $_POST['billing_first_name'] ) && empty( $_POST['billing_first_name'] ) ) {
$errors->add( 'billing_first_name_error', __( 'First name is required!', 'custom-cbi-parts' ) );
}
if ( isset( $_POST['billing_last_name'] ) && empty( $_POST['billing_last_name'] ) ) {
$errors->add( 'billing_last_name_error', __( 'Last name is required!.', 'custom-cbi-parts' ) );
}
if ( isset($_POST['accept_terms']) && $_POST['accept_terms'] == 0 ) {
$errors->add( 'accept_terms_error', __( 'You must accept Terms and Conditions!.', 'custom-cbi-parts' ) );
}
return $errors;
}
I have fixed your code.
add_action( 'woocommerce_register_form_start', 'cbi_custom_woo_account_registration' );
function cbi_custom_woo_account_registration() {
?>
<p class="woocommerce-FormRow woocommerce-FormRow--wide form-row form-row-wide first">
<label for="reg_billing_first_name"><?php _e( 'First name', 'custom-cbi-parts' ); ?> <span class="required">*</span></label>
<input type="text" class="woocommerce-Input woocommerce-Input--text input-text form-control" name="billing_first_name" id="reg_billing_first_name" value="<?php if ( ! empty( $_POST['billing_first_name'] ) ) esc_attr_e( $_POST['billing_first_name'] ); ?>" />
</p>
<p class="woocommerce-FormRow woocommerce-FormRow--wide form-row form-row-wide">
<label for="reg_billing_last_name"><?php _e( 'Last name', 'custom-cbi-parts' ); ?> <span class="required">*</span></label>
<input type="text" class="woocommerce-Input woocommerce-Input--text input-text form-control" name="billing_last_name" id="reg_billing_last_name" value="<?php if ( ! empty( $_POST['billing_last_name'] ) ) esc_attr_e( $_POST['billing_last_name'] ); ?>" />
</p>
<p class="woocommerce-FormRow woocommerce-FormRow--wide form-row form-row-wide">
<label for="accept_terms"><?php _e( 'I agree TeC', 'custom-cbi-parts' ); ?> <span class="required">*</span></label>
<input type="checkbox" class="woocommerce-Input woocommerce-Input--text input-text form-control" name="accept_terms" id="accept_terms" <?php if( isset($_POST['accept_terms'])){ echo "checked"; } ?> />
</p>
<div class="clear"></div>
<?php
}
// 2. VALIDATE FIELDS
add_action( 'woocommerce_registration_errors', 'cbi_validate_custom_reg_fields', 10, 3 );
function cbi_validate_custom_reg_fields( $errors, $username, $email ) {
if ( isset( $_POST['billing_first_name'] ) && empty( $_POST['billing_first_name'] ) ) {
$errors->add( 'billing_first_name_error', __( 'First name is required!', 'custom-cbi-parts' ) );
}
if ( isset( $_POST['billing_last_name'] ) && empty( $_POST['billing_last_name'] ) ) {
$errors->add( 'billing_last_name_error', __( 'Last name is required!.', 'custom-cbi-parts' ) );
}
if ( !isset($_POST['accept_terms']) ) {
$errors->add( 'accept_terms_error', __( 'You must accept Terms and Conditions!.', 'custom-cbi-parts' ) );
}
return $errors;
}

Can't display the value in custom metabox textarea wordpress

Well i tried to make custom meta boxes in page and posts...
I do have the have slider heading and content which i need to make on those specific posts and pages..
I did save the value of heading part in input box..
And in content part i have used Textarea where my value doesn't show up at all..
when i printed the variable that needs to be there i find the value is saving but it doesnt show up
For the code:
<?php function xgr_settings() {
add_meta_box(
'extra-slider-settings', // $id
__( 'Extra Slider Settings', 'xgr' ), // $title
'xgr_add_slider_options_callback',// $callback
array('post','page'),
'normal', // $context
'high' // $priority
);
}
add_action( 'add_meta_boxes', 'xgr_settings' );
$xgr_settings = array(
'slider-heading' => array(
'name' => __('Slider Heading','xgr'),
'value' => 'slider-heading',
'id' => 'slider-heading'
),
'slider-content' => array(
'name' => __('Slider Content','xgr'),
'value' => 'slider-content',
'id' => 'slider-content'
),
);
function xgr_add_slider_options_callback($post){
global $post , $xgr_settings;
?>
<div class="metabox">
<div class="row">
<?php foreach($xgr_settings as $field) {
$headings= get_post_meta($post->ID,$field['id'],true);
var_dump($headings);
?>
<?php if(($field['id']) === 'slider-heading') { ?>
<div class="form-group">
<label style="margin-bottom: 9px; font-style: italic; padding: 15px 10px; line-height: 1.3; vertical-align: middle;" class="control-label f13" for="inputDefault"><?php echo esc_attr( $field['name'] ); ?></label>
<input style="width:100%" type="text" class="form-control" id="<?php echo esc_attr( $field['id'] ); ?>" name="<?php echo esc_attr( $field['value'] ); ?>" value="<?php echo $headings ? $headings : '' ?>">
</div>
<?php
} elseif(($field['id']) === 'slider-content'){ ?>
<div class="form-group">
<label style="margin-bottom: 9px; font-style: italic; padding: 15px 10px; line-height: 1.3; vertical-align: middle;" class="control-label f13" for="inputDefault"><?php echo esc_attr( $field['name'] ); ?></label>
<textarea style="width:100%;min-height:200px;" type="textarea" class="form-control" id="<?php echo esc_attr( $field['id'] ); ?>" name="<?php echo esc_attr( $field['value'] ); ?>" value="<?php echo $headings ? $headings : '' ?>"></textarea>
</div>
<?php } } ?>
<br>
</div>
</div>
<?php
wp_nonce_field( 'xgr_nonce', 'xgr_nonce' );
}
function xgr_save_funtions($post_id){
$heading = sanitize_text_field( $_POST['slider-heading']);
$content = sanitize_text_field( $_POST['slider-content']);
if(isset($POST['xgr_nonce']) && wp_verify_nonce( $POST['xgr_nonce'], 'xgr_nonce')){
return;
}
if(isset($_POST['slider-heading'])){
update_post_meta($post_id ,'slider-heading',$heading);
}
if(isset($_POST['slider-content'])){
update_post_meta($post_id ,'slider-content',$content);
}
}
add_action('save_post','xgr_save_funtions');
TextArea Tag doesn't have value="" parameter
use:
<textarea>{YOUR VALUE TO SHOW}</textarea>
<textarea style="width:100%;min-height:200px;" type="textarea" class="form-control" id="<?php echo esc_attr( $field['id'] ); ?>" name="<?php echo esc_attr( $field['value'] ); ?>" ><?php echo $headings ? $headings : '' ?></textarea>

Add custom fields to nav-menu item

I am trying to add custom data to my menu items (say, for example, data-* attributes) or a dropdown to select the link target, etc.
Through the Screen Options, we have Link Target, Title Attribute, CSS Classes, Link Relationship (XFN) and Description (see screenshot below), but none really offer what I want.
I thought of looking for extensions to Advanced Custom Fields, or something of the sort, but I have not seen anything like it, nor anything through my theme functions.php file.
I finally found a good tutorial with lots of details and explanations as to how to achieve this. The article explains how the WordPress plugin Sweet Custom Menu works, and I've been able to add the functionality to my current theme.
As of today, the plugin hasn't been updated in over two years, but it still does what is expected of it.
You can try Carbon Fields Framework. It provides a custom fields for menu items.
Even if you are using ACF (Advanced Custom Fields) plugin, you still can add the plugin since both can work together.
add_filter( 'wp_edit_nav_menu_walker', 'custom_nav_edit_walker',10,2 );
function custom_nav_edit_walker($walker,$menu_id) {
return 'Walker_Nav_Menu_Edit_Custom';
}
/*
* Saves new field navmenu
*/
add_action('wp_update_nav_menu_item', 'custom_nav_update',10, 3);
function custom_nav_update($menu_id, $menu_item_db_id, $args ) {
if ( is_array($_REQUEST['menu-item-custom']) ) {
$custom_value = $_REQUEST['menu-item-custom'][$menu_item_db_id];
update_post_meta( $menu_item_db_id, '_menu_item_custom', $custom_value );
}
}
/*
* Adds value of new field to Navmenu
*/
add_filter( 'wp_setup_nav_menu_item','custom_nav_item' );
function custom_nav_item($menu_item) {
$menu_item->custom = get_post_meta( $menu_item->ID, '_menu_item_custom', true );
return $menu_item;
}
class Walker_Nav_Menu_Edit_Custom extends Walker_Nav_Menu {
function start_lvl( &$output, $depth = 0, $args = array() ) {}
/**
* Ends the list of after the elements are added.
*
* #see Walker_Nav_Menu::end_lvl()
*
* #since 3.0.0
*
* #param string $output Passed by reference.
* #param int $depth Depth of menu item. Used for padding.
* #param array $args Not used.
*/
function end_lvl( &$output, $depth = 0, $args = array() ) {}
/**
* Start the element output.
*
* #see Walker_Nav_Menu::start_el()
* #since 3.0.0
*
* #global int $_wp_nav_menu_max_depth
*
* #param string $output Used to append additional content (passed by reference).
* #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.
*/
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
global $_wp_nav_menu_max_depth;
$_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
ob_start();
$item_id = esc_attr( $item->ID );
$removed_args = array(
'action',
'customlink-tab',
'edit-menu-item',
'menu-item',
'page-tab',
'_wpnonce',
);
$original_title = false;
if ( 'taxonomy' == $item->type ) {
$original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' );
if ( is_wp_error( $original_title ) ) {
$original_title = false;
}
} elseif ( 'post_type' == $item->type ) {
$original_object = get_post( $item->object_id );
$original_title = get_the_title( $original_object->ID );
} elseif ( 'post_type_archive' == $item->type ) {
$original_object = get_post_type_object( $item->object );
if ( $original_object ) {
$original_title = $original_object->labels->archives;
}
}
$classes = array(
'menu-item menu-item-depth-' . $depth,
'menu-item-' . esc_attr( $item->object ),
'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? 'active' : 'inactive' ),
);
$title = $item->title;
if ( ! empty( $item->_invalid ) ) {
$classes[] = 'menu-item-invalid';
/* translators: %s: title of menu item which is invalid */
$title = sprintf( __( '%s (Invalid)' ), $item->title );
} elseif ( isset( $item->post_status ) && 'draft' == $item->post_status ) {
$classes[] = 'pending';
/* translators: %s: title of menu item in draft status */
$title = sprintf( __( '%s (Pending)' ), $item->title );
}
$title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label;
$submenu_text = '';
if ( 0 == $depth ) {
$submenu_text = 'style="display: none;"';
}
?>
<li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode( ' ', $classes ); ?>">
<div class="menu-item-bar">
<div class="menu-item-handle">
<span class="item-title"><span class="menu-item-title"><?php echo esc_html( $title ); ?></span> <span class="is-submenu" <?php echo $submenu_text; ?>><?php _e( 'sub item' ); ?></span></span>
<span class="item-controls">
<span class="item-type"><?php echo esc_html( $item->type_label ); ?></span>
<span class="item-order hide-if-js">
<a href="
<?php
echo wp_nonce_url(
add_query_arg(
array(
'action' => 'move-up-menu-item',
'menu-item' => $item_id,
),
remove_query_arg( $removed_args, admin_url( 'nav-menus.php' ) )
),
'move-menu_item'
);
?>
" class="item-move-up" aria-label="<?php esc_attr_e( 'Move up' ); ?>">↑</a>
|
<a href="
<?php
echo wp_nonce_url(
add_query_arg(
array(
'action' => 'move-down-menu-item',
'menu-item' => $item_id,
),
remove_query_arg( $removed_args, admin_url( 'nav-menus.php' ) )
),
'move-menu_item'
);
?>
" class="item-move-down" aria-label="<?php esc_attr_e( 'Move down' ); ?>">↓</a>
</span>
<a class="item-edit" id="edit-<?php echo $item_id; ?>" href="
<?php
echo ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? admin_url( 'nav-menus.php' ) : add_query_arg( 'edit-menu-item', $item_id, remove_query_arg( $removed_args, admin_url( 'nav-menus.php#menu-item-settings-' . $item_id ) ) );
?>
" aria-label="<?php esc_attr_e( 'Edit menu item' ); ?>"><span class="screen-reader-text"><?php _e( 'Edit' ); ?></span></a>
</span>
</div>
</div>
<div class="menu-item-settings wp-clearfix" id="menu-item-settings-<?php echo $item_id; ?>">
<?php if ( 'custom' == $item->type ) : ?>
<p class="field-url description description-wide">
<label for="edit-menu-item-url-<?php echo $item_id; ?>">
<?php _e( 'URL' ); ?><br />
<input type="text" id="edit-menu-item-url-<?php echo $item_id; ?>" class="widefat code edit-menu-item-url" name="menu-item-url[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->url ); ?>" />
</label>
</p>
<?php endif; ?>
<p class="description description-wide">
<label for="edit-menu-item-title-<?php echo $item_id; ?>">
<?php _e( 'Navigation Label' ); ?><br />
<input type="text" id="edit-menu-item-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-title" name="menu-item-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->title ); ?>" />
</label>
</p>
<p class="field-title-attribute field-attr-title description description-wide">
<label for="edit-menu-item-attr-title-<?php echo $item_id; ?>">
<?php _e( 'Title Attribute' ); ?><br />
<input type="text" id="edit-menu-item-attr-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-attr-title" name="menu-item-attr-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->post_excerpt ); ?>" />
</label>
</p>
<p class="field-link-target description">
<label for="edit-menu-item-target-<?php echo $item_id; ?>">
<input type="checkbox" id="edit-menu-item-target-<?php echo $item_id; ?>" value="_blank" name="menu-item-target[<?php echo $item_id; ?>]"<?php checked( $item->target, '_blank' ); ?> />
<?php _e( 'Open link in a new tab' ); ?>
</label>
</p>
<p class="field-css-classes description description-thin">
<label for="edit-menu-item-classes-<?php echo $item_id; ?>">
<?php _e( 'CSS Classes (optional)' ); ?><br />
<input type="text" id="edit-menu-item-classes-<?php echo $item_id; ?>" class="widefat code edit-menu-item-classes" name="menu-item-classes[<?php echo $item_id; ?>]" value="<?php echo esc_attr( implode( ' ', $item->classes ) ); ?>" />
</label>
</p>
<p class="field-xfn description description-thin">
<label for="edit-menu-item-xfn-<?php echo $item_id; ?>">
<?php _e( 'Link Relationship (XFN)' ); ?><br />
<input type="text" id="edit-menu-item-xfn-<?php echo $item_id; ?>" class="widefat code edit-menu-item-xfn" name="menu-item-xfn[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->xfn ); ?>" />
</label>
</p>
<p class="field-description description description-wide">
<label for="edit-menu-item-description-<?php echo $item_id; ?>">
<?php _e( 'Description' ); ?><br />
<textarea id="edit-menu-item-description-<?php echo $item_id; ?>" class="widefat edit-menu-item-description" rows="3" cols="20" name="menu-item-description[<?php echo $item_id; ?>]"><?php echo esc_html( $item->description ); // textarea_escaped ?></textarea>
<span class="description"><?php _e( 'The description will be displayed in the menu if the current theme supports it.' ); ?></span>
</label>
</p>
<p class="field-custom description description-wide">
<label for="edit-menu-item-custom-<?php echo $item_id; ?>">
<?php _e( 'Custom' ); ?><br />
<input type="text" id="edit-menu-item-custom-<?php echo $item_id; ?>" class="widefat code edit-menu-item-custom" name="menu-item-custom[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->custom ); ?>" />
</label>
</p>
<fieldset class="field-move hide-if-no-js description description-wide">
<span class="field-move-visual-label" aria-hidden="true"><?php _e( 'Move' ); ?></span>
<button type="button" class="button-link menus-move menus-move-up" data-dir="up"><?php _e( 'Up one' ); ?></button>
<button type="button" class="button-link menus-move menus-move-down" data-dir="down"><?php _e( 'Down one' ); ?></button>
<button type="button" class="button-link menus-move menus-move-left" data-dir="left"></button>
<button type="button" class="button-link menus-move menus-move-right" data-dir="right"></button>
<button type="button" class="button-link menus-move menus-move-top" data-dir="top"><?php _e( 'To the top' ); ?></button>
</fieldset>
<div class="menu-item-actions description-wide submitbox">
<?php if ( 'custom' != $item->type && $original_title !== false ) : ?>
<p class="link-to-original">
<?php
/* translators: %s: original title */
printf( __( 'Original: %s' ), '' . esc_html( $original_title ) . '' );
?>
</p>
<?php endif; ?>
<a class="item-delete submitdelete deletion" id="delete-<?php echo $item_id; ?>" href="
<?php
echo wp_nonce_url(
add_query_arg(
array(
'action' => 'delete-menu-item',
'menu-item' => $item_id,
),
admin_url( 'nav-menus.php' )
),
'delete-menu_item_' . $item_id
);
?>
"><?php _e( 'Remove' ); ?></a> <span class="meta-sep hide-if-no-js"> | </span> <a class="item-cancel submitcancel hide-if-no-js" id="cancel-<?php echo $item_id; ?>" href="
<?php
echo esc_url(
add_query_arg(
array(
'edit-menu-item' => $item_id,
'cancel' => time(),
),
admin_url( 'nav-menus.php' )
)
);
?>
#menu-item-settings-<?php echo $item_id; ?>"><?php _e( 'Cancel' ); ?></a>
</div>
<input class="menu-item-data-db-id" type="hidden" name="menu-item-db-id[<?php echo $item_id; ?>]" value="<?php echo $item_id; ?>" />
<input class="menu-item-data-object-id" type="hidden" name="menu-item-object-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object_id ); ?>" />
<input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object ); ?>" />
<input class="menu-item-data-parent-id" type="hidden" name="menu-item-parent-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_item_parent ); ?>" />
<input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_order ); ?>" />
<input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->type ); ?>" />
</div><!-- .menu-item-settings-->
<ul class="menu-item-transport"></ul>
<?php
$output .= ob_get_clean();
}
}

Resources