WordPress plugin from own server

All Credit to the following post goes to Abid Omar. The full tutorial can be found on Tuts+: A Guide to the WordPress HTTP API: Automatic Plugin Updates View Plugin On Github The gist is to create a new class which will post an external file ( API ) and return plugin to download if … Read more

How to add multiple custom URL variables?

I pretty sure this filter lets you add an array of variables. I’ve not tested this: function add_custom_query_vars( $vars ){ $vars[] = “variable1”; $vars[] = “variable2”; $vars[] = “variable3”; //… etc return $vars; } add_filter( ‘query_vars’, ‘add_custom_query_vars’ ); Or another way of doing it would be to do this: function add_custom_query_vars( $vars ){ array_push($vars, “variable1”, … Read more

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’);