0
votes

I've created a custom Wordpress plugin. I set a menu item on the left side of the Admin panel which links to the main page for the plugin which I can access. Works fine.

I then put a link on that main plugin page in order to be able to click a link that runs a PHP script, but it returns a blank page. This URL syntax is confusing within the Admin section for Plugins. I just want to call my script!

I'm doing what is suggested here, but it just serves up a blank page: http://codex.wordpress.org/Plugin_API/Action_Reference/admin_post_%28action%29

Why is it so hard to just link to a page and call a function from a Plugin within the Admin section? I have Debug Mode enabled, too.

Thanks.

1
Ok, the blank page issue was fixed since I was calling admin.php?action=foo_bar&id=1. I changed it to be admin-post.php and it worked. but now it is rendering without any theme / html around it, literally just the raw text my function is returning. How can I just get a link to work in the admin section??SH10151
I'm thinking admin_post.php and adding an "admin_post" action isn't even the right thing for what I need. I just want to create a link that executes a function in my Plugin. Any other "actions" I should be using? Something else entirely?SH10151

1 Answers

0
votes

Wow, this was confusing. With a little help from http://clivern.com/adding-menus-and-submenus-for-wordpress-plugins/ I now understand that you can't just link to your own plugin functions and pages in the Wordpress Admin section. You have to create menu items using add_menu_page() and add_submenu_page () that are then interpreted by Wordpress as blocks of code shown on a page...

Man this is frustrating and strange and it took HOURS just to figure this stupid little thing out. Really poorly documented. I found a few other things in the "Plugin Handbook" but nothing to do with this. They don't get into how to write a plugin that has admin-only functionality and being able to link to those functions and how the Admin URL syntax works.