[Wordpress][Nextgen Gallery] How reorder admin menu position - wordpress

Is it possible to move Nextgen Gallery icon under Media in Admin Menu?
I know how to reorder Admin menu items:
function new_menu_order($new_order) {
if (!$new_order) return true;
return array(
'index.php',
'edit.php',
'edit.php?post_type=page',
'upload.php', //Media icon
'admin.php?page=nextgen-gallery', // Nextgen Gallery link
'edit.php?post_type=slide'
);
}
add_filter('custom_menu_order', 'new_menu_order');
add_filter('menu_order', 'new_menu_order');
But adding "admin.php?page=nextgen-gallery" in this code doesn't help. Gallery is still last position.

Ok, I've found a kind of solution: I had to edit admin.php in plugin admin folder using a add_menu_page

It seems due to the priority
Have you tried by setting lower priority to the filters? You can try by settings priority as 99999 as below.
add_filter('custom_menu_order', 'new_menu_order', 99999);
add_filter('menu_order', 'new_menu_order', 99999);

Related

How do I get rid of the comments dropdown in the WordPress dashboard?

The code below removes everything I want except for the comments dropdown.
That pesky little icon just won't go away. Is there another method?
// Remove Admin bar links
function remove_admin_bar_links() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo'); // Remove the Wordpress logo
$wp_admin_bar->remove_menu('about'); // Remove the about Wordpress link
$wp_admin_bar->remove_menu('wporg'); // Remove the Wordpress.org link
$wp_admin_bar->remove_menu('documentation'); // Remove the Wordpress documentation link
$wp_admin_bar->remove_menu('support-forums'); // Remove the support forums link
$wp_admin_bar->remove_menu('feedback'); // Remove the feedback link
$wp_admin_bar->remove_menu('comments'); // Remove the comments link
$wp_admin_bar->remove_menu('new-content'); // Remove the content link
}
add_action( 'wp_before_admin_bar_render', 'remove_admin_bar_links' );
You can use:
function remove_toolbar_node(\WP_Admin_Bar $wp_admin_bar) {
$wp_admin_bar->remove_node('comments');
}
add_action('admin_bar_menu', 'remove_toolbar_node', 999);
Note that you can use $wp_admin_bar->get_nodes() to get available nodes.
Figured out I have to add: $wp_admin_bar->remove_menu('notes');
That gets rid of the comments icon.

How to add custom link NOT http to Wordpress menu? I want to add link viber://add?number=0000000000

I want to add custom link NOT http to wordpress menu. But after adding, the field is automatically cleared. How to fix it? I want to add link viber://add?number=0000000000
Appearance => Menus => Custom Links (https://i.imgur.com/H41mIwf.png)
in functions.php add
add_filter( 'kses_allowed_protocols', function ( $protocols ) {
$protocols[] = 'viber';
return $protocols;
} );
https://developer.wordpress.org/reference/hooks/kses_allowed_protocols/

Remove Option Tree menu in admin page

I integrated option tree in my template.
I want to hide OptionTree menu item from users. How to remove Option Tree menu item in admin page?
Add this code to your theme's functions.php:
// Remove Option Tree Settings Menu
add_filter( 'ot_show_pages', '__return_false' );
That will remove the Option Tree admin menu.
Here is another solution.
function remove_ot_menu () {
remove_menu_page( "ot-settings" ); } add_action( 'admin_menu', 'remove_ot_menu' );
I know i'm late to the party but since i got to find
a solution (for an old website i restructering) i tought
i might share "a softer" solution.
2 steps
1. We ad the current user id to the admin body class
2. We add a css to hide the menu except for the intended user.
User id in the body class
/*********************************************
** CUSTOM BODY CLASS
*********************************************/
add_filter('admin_body_class', 'custom_admin_body_class');
function custom_admin_body_class($classes){
$cuserid = get_current_user_id();
return $classes. 'user-'.$cuserid;
}
Add the desired css to anytype of css loaded to wp-admin
** replace user-[number] with yours*
.wp-admin:not(.user-1) #toplevel_page_ot-settings {display: none;}
If your not loading any css to wp-admin you can use this
add_action('admin_head', 'my_custom_fonts');
function my_custom_fonts() {
echo '<style>.wp-admin:not(.user-1) #toplevel_page_ot-settings {display: none;}</style>';
}

Wordpress remove menu items from wp-admin

I want that in wp-admin will be only Posts, Pages and Settings, it's possible to remove al remaining Media, Plugins, Users, Tools etc.
This function remove only from dashboard remove_menu_page( 'upload.php' );
Remove that menus from $restricted, that you want to prevent.
function remove_menus () {
global $menu;
$restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('Links'), __('Pages'), __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('Plugins'));
end ($menu);
while (prev($menu)){
$value = explode(' ',$menu[key($menu)][0]);
if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
}
}
Credit goes to hungred via wprecipes
Since WordPress 3.1 you can better use remove_menu_page()
add_action( 'admin_menu', 'prefix_remove_menu_pages' );
function prefix_remove_menu_pages() {
remove_menu_page('edit-comments.php');
remove_menu_page('upload.php');
remove_menu_page('tools.php');
// Remove any item you want
}
}
from the docs:
Please be aware that remove_menu_pages would not prevent a user from accessing
these screens directly. Removing a menu does not replace the need to
filter a user's permissions as appropriate.
And for submenu items:
To remove submenu items in the admin, use remove_submenu_page. Using
remove_menu_page() will not work for submenu items.

Genesis child theme - Remove primary sidebar on homepage only

I have been looking all over the place and am unable to find a solution. I am using Genesis Child theme "news" and for the homepage I don't need the primary sidebar, because I'll have an image slider there instead. I have found code such as this:
/** Force full width layout */
add_filter( 'genesis_pre_get_option_site_layout', 'child_do_layout' );
function child_do_layout( $opt ) {
$opt = 'full-width-content'; // You can change this to any Genesis layout below
return $opt;
}
and added it to the functions page, because I want to essentially force a full width page for home.php, however it hasn't worked.
If anyone has had success with this, any help is appreciated.
nevermind, I found the solution to anyone who is curious, to the home.php file add:
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );

Resources