Searching, reading, learning … then improve … :p)

After knowing more about Wordpress MU (wpmu), I know that my first plugin for Wordpress MU (Custom CSS menu) is not good in term of coding. It use two separate file, which is actually possible to use only one. Not only two files, but also need to copy one of them to wp-admin folder.

For you who like that plugin (like me :p), just download the latest ones from here. Save the file as a PHP file (if you don’t know how: right click, and then Save Link As … / Save Target As … rename the destination file to “ccss.php”), and copy it to your wp-content/mu-plugins folder, and you will get the additional Custom CSS sub-menu under the Design menu.

The difference between the 1st version and this update is the function that is used to insert this plugin into the core code. When I wrote the 1st version, I only knew about adding the submenu item using add_action() and the global variable $submenu. I did try some function about adding submenu, but always failed (I guess, I missunderstood some explanation from codex.wordpress.org developer’s document).

Then, I found an interesting example from Power Tools plugin. It use add_action and add_submenu_page to insert both submenu item and submenu function. I try with my own style of coding, and it works.

add_action is a function to add our own function to the main wordpress function. For example, if we call add_action('admin_menu', 'our_own_test_function1'); then wordpress will also execute function called our_own_test_function1 when the main admin_menu function is called.

add_submenu_page is a function to add our submenu item into the parent menu. The syntax is : add_submenu_page(parent, page_title, submenu_title, user_level, file_or_pageid, function_name). If we want to ‘include’ our function_name to the parent (file), then we must supply the unique pageid, and use it in our form action (<form action="parent?page=pageid">).

Hope it is useful,