Is it possible to get activate plugin list in wordpress and remove it from admin menu bar ?. i want to remove all activate plugin links from adminu bar .
Findout the page and replace your_plugin_page .
<?php
function remove_menus(){
remove_menu_page( 'your_plugin_page.php' ); //probably where the plugin settings are available
}
add_action( 'admin_menu', 'remove_menus' );
?>
This will list out all activated plugins:-
$apl=get_option('active_plugins');
$plugins=get_plugins();
$activated_plugins=array();
foreach ($apl as $p){
if(isset($plugins[$p])){
array_push($activated_plugins, $plugins[$p]);
}
}
now you need to get all the pages .Not a perfect solution , but I hope it will be helpful.
Related
I'm working on a wordpress website where i have a problem. I need to change the main menu and remove some entries, theese entries are removed only for logged in users, if i go to the website as anonymous user i see the original menu with all elements. I'm going crazy.
use this https://wordpress.org/plugins/if-menu/,
or you can use "is_admin" in four functions.php too.
For that, you will need to remove those items from your menu and then please place the following code in your functions.php file, and replace the items and links
function add_login_logout_register_menu( $items, $args ) {
if ( $args->theme_location != 'primary' ) {
return $items;
}
if ( is_user_logged_in() ) {
$items .= '<li class="right">'. __("item1") .'</li>';
$items .= '<li class="right">'. __("item1") .'</li>';
}
return $items;
}
add_filter( 'wp_nav_menu_items', 'add_login_logout_register_menu', 199, 2 );
i already installed "IF MENU" plugin, but it didn't work for my website, so i removed id. after that, i cannot update the "anonymous" menu anymore (it seems to happen mainly in the home page). It seems that IF MENU broken my website
I need to hide / remove a menu and submenu in WordPress backend.
Main menu item:
admin.php?page=themeit_dashboard
Sub menu items:
admin.php?page=themeit_dashboard&tab=builder
admin.php?page=_options&tab=1
admin.php?page=themeit_dashboard&tab=license
I have tried the code below code, but that does not work. Two of the subpages link to the same page but show different tabs.
function remove_menus(){
if ( !current_user_can( 'manage_options' ) ) {
remove_menu_page( 'admin.php?page=themeit_dashboard' ); //themeit
remove_submenu_page( 'admin.php?page=themeit_dashboard', 'admin.php?page=themeit_dashboard&tab=builder' ); //themeit
remove_submenu_page( 'admin.php?page=_options', 'admin.php?page=_options&tab=1' ); //themeit
remove_submenu_page( 'admin.php?page=themeit_dashboard', 'admin.php?page=themeit_dashboard&tab=license' ); //themeit
}
}
add_action( 'admin_menu', 'remove_menus' );
You can do it by using current_user_can() and remove_menu_page, as you tried to do.
But It can be done by without coding too.... long back I was using a plugin called - "Advanced Access Manager". Use that or any similar plugins.
With those you will be able to assign permisson on menus based on roles with a cool UI.
I personally did found it very easy.
wp-content/plugins/myplugin.php
how to assign this plugin to top level menu? E.g. menu on my website: about us contacts, services my plugin. I'm using add_menu_page but I dont know why its not working.
I have used it, when prepare my theme. You may used it also. Put it at functions.php
add_action( 'admin_menu', 'register_YOURPLUGINNAME_menu_page' );
function register_YOURPLUGINNAME_menu_page(){
add_menu_page( 'PLUGIN Info', 'PLUGINNAME', 'manage_options', 'custompage', 'YOURPLUGIN_menu_page', 'dashicons-tickets' , 10 );
}
function YOURPLUGIN_menu_page(){
?>
<h1>TEST YOUR MIGHT :)
<?php
}
?>
I have created a theme options page for my WordPress theme with the following code in functions.php file:
add_action( 'admin_menu', 'register_options_page' );
function register_options_page()
{
$my_hook = add_menu_page( 'Theme Options', 'Theme Options', 'manage_options', 'merry_options', 'get_theme_options', 'dashicons-share-alt', 99 );
// var_dump($my_hook); die();
}
function get_theme_options()
{
include_once get_template_directory()."/framework/themeoptions.php";
}
As you can see, it includes an external page located at .../framework/themeoptions.php. Now the problem is anyone can go and open that URL to access this page directly. I want that page only to accessed when the WordPress admin is signed in. Can you tell me the right way to do it?
I would suggest the following function:
if ( is_admin() ) {
echo "You are viewing the WordPress Administration Panels";
} else {
echo "You are viewing the theme";
}
as the right way to check for administrator privileges.
You can read more about this function in the Wordpress Codex: http://codex.wordpress.org/Function_Reference/is_admin
Figured out a way. I can use
<?php if (current_user_can('administrator')) { }?>
to see if WordPress admin is accessing the page. Is there a better approach?
I am creating a dedicated theme for an app with some custom settings that will be used just a few times to set up the app from a fresh wordpress install.
How do I create a top level menu in wordpress admin for a twenty twelve child theme via functions.php and a page to contain the settings? I would like to have it as the first item in the menu.
Here's a solution. Just put this code in the functions.php
<?php
/******* New menu item for admin *********/
add_action( 'admin_menu', 'register_my_custom_menu_page' );
function register_my_custom_menu_page(){
add_menu_page( 'custom menu title', '♥Custom theme options♥', 'manage_options', 'custompage', 'my_custom_menu_page', '' /* or something like ... plugins_url( 'myplugin/images/icon.png' )*/, 1 );
}
function my_custom_menu_page(){
?>
Hello world. This is a simple example page.
<?php
}
?>