enqueue script during add menu items means before save menu items

Because this menu items are appended with ajax response you need to run this JS functions again for each item that you add to the menu with the document#menu-item-added event. Add something like this in your JS file. $(document).on(‘menu-item-added’, function(event, markup) { // debug that the hook work console.log(markup); $.each(markup, function(index, menuItem) { if(menuItem.id) { … Read more

Remove Elementor Menu From WordPress Admin

This would work for editors. You can swap the role in and out depending on which role you are trying to target (e.g., editor, subscriber, etc.). This would go in functions.php of your child theme. function remove_menus(){ // get current login user’s role $roles = wp_get_current_user()->roles; // test role if( !in_array(‘editor’,$roles)){ return; } //remove menu … Read more

Admin submenu issue with PHP not detecting two strings as equal

string(77) “edit-tags.php?taxonomy=acs-field-group-category&post_type=acs-field-group” string(73) “edit-tags.php?taxonomy=acs-field-group-category&post_type=acs-field-group” Same string, different length! No, they’re not the same string — if you had viewed the raw/server-generated HTML source, or used this instead of the var_dump($submenu_file);: echo ‘<pre>’; var_dump($submenu_file, $sub_item[2]); echo ‘</pre>’; Then you would have seen the correct string which uses &amp; instead of just &: string(77) “edit-tags.php?taxonomy=acs-field-group-category&amp;post_type=acs-field-group” So that … Read more

Using menu_position to add two entries between Dashboard and Posts

The order of the menu items can be changed using the filter menu_order add_filter( ‘menu_order’, ‘se354759_menu_order’ ); add_filter( ‘custom_menu_order’, ‘__return_true’ ); function se354759_menu_order ($menu_order) { $cpts = [ ‘edit.php?post_type=” . “custom-post-type’, ‘edit.php?post_type=” . “another-cpt’ ]; // // remove and save first item (“dashboard”) in variable $first_item = array_shift( $menu_order ); foreach( $cpts as $ctp ) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)