How to break line / add to ADMIN menu

Disclaimer: This question is not about "frontend" nav menu

I am looking for a way how to break line in a menu item label in WP admin sidebar menu, sidereason is that the custom post type label I am registering is too long for 1 line and I don’t really want to mess with the width of the admin menu.

I tried adding both "\n" and <br> into the custom post type label, but <br> gets escaped and line breaks are not converted.

I tried to look on the Internet, but I mainly found articles how to line break in "frontend" menu items which is not what I am looking for.

Is there some sort of filter or other way to do this?

Note: I would also like to avoid tinkering with anything global or special characters like nonbreaking hyphen, if possible
Note2: I know there is auto linebreak in place, however I need a manually added line break because the term is in some-thing format so it breaks on dash which is unwanted behavior

How to loop nav menu items in WordPress menu Walker?

I want to loop every single item in the menu with the walker class.

class Primary_Walker_Nav_Menu extends Walker_Nav_Menu {     public $  bg;      function __construct() {         $  this->bg = get_field('navigation_menu_background_image', 'option'); //acf array in function.php     }           } 

In $ this->bg are an array of images, I want to have $ depth less from 0, which means the only the first item in-depth, not sub-menu, nothing else.

My idea is to loop $ i item and get $ bg item on position $ i, how to do this?

Help, thanks!

Add a counter beside menu item label

I’m using the following code to add a panel to the admin menu screen, so the users are able to add a Cart link to their menus:

function my_add_meta_box() {     add_meta_box( 'custom-meta-box', __( 'Cart' ), 'my_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' ); } add_action( 'admin_init', 'my_add_meta_box' );  function my_nav_menu_item_link_meta_box() {     global $  _nav_menu_placeholder, $  nav_menu_selected_id;     $  _nav_menu_placeholder = 0 > $  _nav_menu_placeholder ? $  _nav_menu_placeholder - 1 : -1;     ?>     <div id="posttype-cart" class="posttypediv">         <div id="tabs-panel-cart" class="tabs-panel tabs-panel-active">             <ul id="cart-checklist" class="categorychecklist form-no-clear">                 <li>                     <label class="menu-item-title">                         <input type="checkbox" class="menu-item-checkbox" name="menu-item[<?php echo (int) $  _nav_menu_placeholder; ?>][menu-item-object-id]" value="-1"> <?php esc_html_e( 'Cart' ); ?>                     </label>                     <input type="hidden" class="menu-item-type" name="menu-item[<?php echo (int) $  _nav_menu_placeholder; ?>][menu-item-type]" value="post_type">                     <input type="hidden" class="menu-item-object" name="menu-item[<?php echo (int) $  _nav_menu_placeholder; ?>][menu-item-object]" value="page">                     <input type="hidden" class="menu-item-object-id" name="menu-item[<?php echo (int) $  _nav_menu_placeholder; ?>][menu-item-object-id]" value="<?php echo get_option( 'cart_page_id' ); ?>">                     <input type="hidden" class="menu-item-title" name="menu-item[<?php echo (int) $  _nav_menu_placeholder; ?>][menu-item-title]" value="<?php esc_html_e( 'Cart' ); ?>">                 </li>             </ul>         </div>         <p class="button-controls">             <span class="add-to-menu">                 <input type="submit" <?php disabled( $  nav_menu_selected_id, 0 ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-post-type-menu-item" id="submit-posttype-cart">                 <span class="spinner"></span>             </span>         </p>     </div>     <?php } 

My question is, is it possible to dynamically add a counter that shows the number of items in cart beside the Cart menu item label in the frontend? If so, how? I think that the wp_get_nav_menu_items filter might be useful for this, but how can I identify the Cart menu item in there to be able to modify its label in the frontend on the fly?

function my_get_nav_menu_items( $  items ) {     foreach ( $  items as $  item ) {         if ( is_cart_menu_item( $  item ) ) {             // add a counter beside the Cart menu item label             }     }     return items; } add_filter( 'wp_get_nav_menu_items', 'my_get_nav_menu_items', 20 ); 

Clicking custom plugin admin menu redirects to “No Update Required” on live site

I built a custom WordPress plugin that sends woocommerce purchase info to a CRM. The plugin works perfectly on localhost. But on live site, whenever I click on the admin menu, I always get redirected to "No Update Required" page.

enter image description here

Here is my main plugin file:

/**  * Plugin Name: Woo Crm  * Description: Sends customer data to the CRM on purchase.  */  if (!defined('ABSPATH')) {     echo 'I am a plugin I cannot do anything when called directly.';     exit; }  // Config define('PLUGIN_NAME', 'Woo Crm'); define('PLUGIN_SLUG', 'woo_crm'); define('PLUGIN_URL', plugin_dir_url(__FILE__)); define('PLUGIN_PATH', plugin_dir_path(__FILE__));  // Imports require_once(PLUGIN_PATH . 'utils/utils.php'); require_once(PLUGIN_PATH . 'views/views.php'); require_once(PLUGIN_PATH . 'services/crm/crm.php'); require_once(PLUGIN_PATH . 'views/components/settings/settings.php');  class WooCrm {     function __construct()     {         // Register Styles         add_action('admin_enqueue_scripts', array($  this, 'register_styles'));          // Create Menu Page         add_action('admin_menu', array($  this, 'plugin_setup_menu'));          // Add Settings Fields to Menu Page         add_action('admin_init', array('settings', 'init'));          // Woocommerce hook         /**          * First check if WooCommerce is activated          * Then check if hook isn't empty          */         if (class_exists('WooCommerce')) {             $  hook = get_when_to_send_data_hook();             if (!empty($  hook)) {                 add_action($  hook, array($  this, 'woo_order_create_client'));             }         }     }      function woo_order_create_client($  order_id)     {         // Create client logic     }      function plugin_setup_menu()     {         $  icon_url = PLUGIN_URL . "public/images/dash-icon.png";         add_menu_page(__(PLUGIN_NAME, PLUGIN_SLUG), __(PLUGIN_NAME, PLUGIN_SLUG), 'manage_options', PLUGIN_SLUG, array('views', 'admin'), $  icon_url);     }      function register_styles()     {         wp_register_style('woo_crm_admin', PLUGIN_URL . 'public/css/admin.css');         wp_enqueue_style('woo_crm_admin');     }  }  new WooCrm(); 

Any help would be highly appreciated.

Is this issue with my mobile or the mobile menu is not working

hello friends,

I have made a bootstrap template
but for some reasons when i open the wbesite on mobile the mobile menu and the preloader animation doesn't seem to work..although it works on several online browser testing website

when i open the website in my mobile ..i see this
golf tdi 0 60
and the a javascript doesn't work at all to close the menu

any help will…

Is this issue with my mobile or the mobile menu is not working

Cannot add custom taxonomy to specific menu

I’m trying to add a custom taxonomy to a menu, but for some reason it won’t show.

This is the custom post type that I want use to associate the taxonomy:

$  labels = array(     'name' => 'Esperienza',     'singular_name' => 'Esperienza',     'menu_name' => 'Esperienza',     'all_items' => 'Esperienza',     'add_new' => 'Aggiungi nuovo',     'add_new_item' => 'Aggiungi nuova Esperienza',     'edit' => 'Modifica',     'edit_item' => 'Modifica Esperienza',     'new_item' => 'Aggiungi nuova Esperienza',     'view' => 'Visualizza Esperienza',     'view_item' => 'Visualizza Esperienza',     'search_items' => 'Cerca Esperienza',     'not_found' => 'Nessun Esperienza trovata',     'not_found_in_trash' => 'Nessun Esperienza trovata',     'parent' => 'Esperienza genitore',     'filter_items_list'     => 'Esperienza $  s',     'items_list_navigation' => 'Navigazione',     'items_list'            => 'Lista Esperienza',     'view items'    =>    'Visualizza Esperienza',     'attributes'    =>    'Attributi Esperienza' );  $  args = array(     'labels'  => $  labels,     'public' => true,     'publicly_queryable' => true,     'show_ui' => true,     'query_var' => true,     'rewrite' => array('slug' => 'st_experiences'),     'has_archive' => true,     'hierarchical' => false,     'menu_position' => 0,     'show_in_menu' => 'edit.php?post_type=st_tours',     'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments'),     'taxonomies' => array('st_experience_categories') );  register_post_type('st_experiences', $  args); 

and this is the custom taxonomy:

function experience_category_post_type() {     $  labels = [         'name' => __('Categorie esperienze', 'traveler'),         'singular_name' => __('Categorie esperienze', 'traveler'),         'search_items' => __('Search Categorie esperienze', 'traveler'),         'popular_items' => __('Popular Categorie esperienze', 'traveler'),         'all_items' => __('All Categorie esperienze', 'traveler'),         'parent_item' => null,         'parent_item_colon' => null,         'edit_item' => __('Edit Categorie esperienze', 'traveler'),         'update_item' => __('Update Categorie esperienze', 'traveler'),         'add_new_item' => __('Add New Categorie esperienze', 'traveler'),         'new_item_name' => __('New Experience Type Name', 'traveler'),         'separate_items_with_commas' => __('Separate Categorie esperienze with commas', 'traveler'),         'add_or_remove_items' => __('Add or remove Categorie esperienze', 'traveler'),         'choose_from_most_used' => __('Choose from the most used Categorie esperienze', 'traveler'),         'not_found' => __('No Categorie esperienze.', 'traveler'),         'menu_name' => __('Categorie Esperienze', 'traveler'),     ];      register_taxonomy('st_experience_categories', array('st_experiences'), array(         'labels' => $  labels,         'show_ui' => true,         'show_admin_column' => true,         'query_var' => true,         'rewrite' => array('slug' => 'st_experience_categories'),         'show_in_menu' => 'edit.php?post_type=st_tours',         'show_in_nav_menus' => true,         'hierarchical' => true     )); }  add_action('init', 'experience_category_post_type'); 

when I visit my custom post I correctly see the taxonomy on the right menu:

enter image description here

but on the left side menu I can’t get displayed:

enter image description here

what I did wrong?

WordPress add page under admin submenu and retaining the active status of the parent submenu page in the menu

I have added a page in the admin menu(pxmag-menu) and a submenu(pxmag-plans). There is another page(pxmag-plans-edit) set under the submenu(pxmag-plans) as the parent page.

public function __construct() {     require('pxMagAdminPlans.class.php');     $  this->admPlanObj= new pxMagAdminPlans();      add_action('admin_menu', array($  this, 'add_plan_admin_menu')); }  public function add_plan_admin_menu() {     add_menu_page(__('Dashboard', 'textdomain'), get_bloginfo('name'), 'manage_options', 'pxmag-menu', array($  this, 'pxmag_dash'), 'dashicons-welcome-view-site', 6);              add_submenu_page('pxmag-menu', __('Subscription Plans', 'textdomain'), 'Plans', 'manage_options', 'pxmag-plans', array($  this->admPlanObj, 'plan_admin_menu_page'));     add_submenu_page('pxmag-plans', __('Add/edit Plans', 'textdomain'), 'Add/edit plans', 'manage_options', 'pxmag-plans-edit', array($  this->admPlanObj, 'plan_admin_menu_edit')); } 

All the menu and submenu pages load fine.

But, when I open this page(pxmag-plans-edit), the menu selection in the WordPress admin shows nothing as current item, whereas the pxmag-plans is supposed to be the current selection.

(It is supposed to work like: when I click ‘Posts > Categories‘ and subsequently open the ‘edit category‘ page, the ‘Posts > Categories‘ option in menu keeps selected).

What is going wrong? What is the correct process?