How to remove duplicate sub-menu name for top level menu items in a plugin?

If you dont want ‘TopLevel’ menu to represent a custom page you can use: add_menu_page( ‘TopLevel’, ‘TopLevel’, ‘MENU_CAP_LVL’, ‘MENU_SLUG’, ‘MENU_CB’ ); add_submenu_page( ‘MENU_SLUG’, ‘SubMenu’, ‘SubMenu’, ‘MENU_CAP_LVL’, ‘SUB_MENU_SLUG’, ‘SUB_MENU_CB’ ); add_submenu_page( ‘MENU_SLUG’, ‘SubMenu-A’, ‘SubMenu-A’, ‘MENU_CAP_LVL’, ‘SUB_MENU_A_SLUG’, ‘SUB_MENU_A_CB’ ); remove_submenu_page(‘MENU_SLUG’,’MENU_SLUG’); In this way click on “TopMenu” will forward to the 1st “SubMenu” and prevent “TopLevel” from being … Read more

What is the recommended way to create plugin administration forms?

I personally just add a menu link and in the function for it handle the form. With $_SERVER[‘REQUEST_URI’] as the action. Example below. add_action(“admin_menu”, “menu” ); function menu(){ add_menu_page(‘Test form’, ‘Test form’, ‘manage_options’, ‘show_form’ ); } function show_form(){ if ( $_SERVER[“REQUEST_METHOD”] == “POST” ){ print “do stuff”; } else { ?><form method=”post” action=”<?php echo $_SERVER[‘REQUEST_URI’]; … Read more

Advice on naming files for a plugin

There’s certainly no need to name plugin files with prefixes (although some plugin authors like to do this). I suspect the advice you read was referring to functions within your plugin files. Structuring you plugin folders as you suggest (using a class folder) is fine. See this link for more information on writing plugins: http://codex.wordpress.org/Writing_a_Plugin … Read more

Redirect to settings page after install

Register an activation hook and then redirect the user’s browser when you’re done installing your plugin. function myplugin_activate() { // TODO: Install your plugin here. // I don’t know of any other redirect function, so this’ll have to do. wp_redirect(admin_url(‘options-general.php?page=myplugin_settings’)); // You could use a header(sprintf(‘Location: %s’, admin_url(…)); here instead too. } register_activation_hook(__FILE__, ‘myplugin_activate’);

PHPUnit testing WordPress Plugin

The reason the WordPress test bootstrap is loaded at the end is precisely because it loads WordPress: // Load WordPress require_once ABSPATH . ‘/wp-settings.php’; If you don’t hook your function to load your plugin to ‘muplugins_loaded’ before including the bootstrap, your plugin won’t be loaded with WordPress. In most cases that will mean that your … Read more

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