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
}
?>
Related
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.
Does anyone knows how to remove the menu link named "Updates", found under the "Dashboard" section of the Wordpress Administration Menu?
I added the following actions & filters, which stop the core, theme & plugins updates, but the menu link is still there, although there is nothing to update:
# Disable WP>3.0 core updates
add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
# Disable WP>3.0 plugin updates
remove_action( 'load-update-core.php', 'wp_update_plugins' );
add_filter( 'pre_site_transient_update_plugins', create_function( '$a', "return null;" ) );
# Disable WP>3.0 theme updates
remove_action( 'load-update-core.php', 'wp_update_themes' );
add_filter( 'pre_site_transient_update_themes', create_function( '$a', "return null;" ) );
# disable edit plugin and theme files:
define('DISALLOW_FILE_EDIT',true);
# disable core updates:
add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
Thank you,
Ciprian
#wunderdojo wasn't "wrong", but WordPress has a bit of a better built in mechanism to handle this.
What you want (or anyone else viewing this these days) is a function called remove_submenu_page
Codex link: https://codex.wordpress.org/Function_Reference/remove_submenu_page
add_action( 'admin_menu', 'control_menu_items_shown' );
function control_menu_items_shown() {
remove_submenu_page( 'index.php', 'update-core.php' );
}
index.php is the name for the "Dashboard" menu item and update-core.php is the name for the "Updates" menu sub item.
Please note the naming mechanisms of these change quite a bit depending on the plugin, theme, etc.
Example from the Mandrill plugin:
remove_submenu_page( 'options-general.php', 'wpmandrill' );
They may not end in .php
It's also worth noting a similiar function remove_menu_page
Codex link: https://codex.wordpress.org/Function_Reference/remove_menu_page
Hope someone finds this useful in the future.
The update options comes in two places in back-end. One as the message on top and second in the 'AT a glance' window in dashboard. Place the below code in your functions.php. This code will hide the update options from these two areas.
add_action('admin_menu','wphidenag');
function wphidenag() {
remove_action( 'admin_notices', 'update_nag', 3 );
}
function admin_style() { ?>
<style>
#wp-version-message a.button{
display:none;
}
</style>
<?php
}
add_action('admin_enqueue_scripts', 'admin_style');
This should do it:
function edit_admin_menus() {
global $submenu;
unset($submenu['index.php'][10]);
return $submenu;
}
add_action( 'admin_menu', 'edit_admin_menus' );
Put that in your theme's functions.php file or in your plugin code.
I am trying the following syntax to add the custom menu on dashboard. and I put this code in 'function.php' in theme folder file. but its not displaying menu on dashboard. So, please help me in which file I put this code? otherwise any other solution please help me.
<?php
add_action( 'admin_menu', 'register_my_custom_menu_page' );
function register_my_custom_menu_page(){
add_menu_page( 'custom menu title', 'custom menu', 'manage_options', 'custompage', 'my_custom_menu_page', plugins_url( 'myplugin/images/icon.png' ), 6 );
}
function my_custom_menu_page(){
echo "Admin Page Test";
}
?>
In which function.php file are you writing this code? are you writing in the core files? if you are writing in the theme's function file just make sure that the theme is currently active.
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
}
?>
I tried hundrad of times to load a custom page when top level menu items are clicked.
add_menu_page('Hotels', 'Hotels', 'administrator', 8, 'main_menu_foo');
Where should I put my "view-hotels.php" file?
I want to built a menu as
[Hotels]
[Hotels] //points to view-hotel.php
[Add new...] // points to add-hotel.php
Add menu page needs a call back function to render the page. You can wrap your page in a function and add with an include or you could include the page using your callback function. Also 'administrator' is not a capability. Heres an example:
add_action( 'admin_menu', 'add_admin_menus' )
function add_admin_menus() {
add_menu_page( 'Hotels', 'Hotels', 'manage_options', call_back_function );
}
call_back_function() { ?>
<div class="wrap">
<?php wp_nonce_field( 'hotels' );
hotels_page_function(); ?>
</wrap>
<?php }
include_once( '/view-hotels.php' );