Tonight, I’ll write some code after a long time, by writing a wordpress plugin and chronicling every step of the way.
What I used:
I reinstalled windows after a nasty virus attack, but managed to get everything I required to get started: Firefox, xampp, and Dreamweaver CS3
Step 1: Install wordpress and Configure: 9:20
After setting the databases, and security settings for xampp, I installed wordpress 2.2 with minimal trouble. Also opened up several pages with information about the plugin api for wordpress.
Step 2: Create the plugin file: 9:25.
Created the plugin php in the Code folder of My Documents. Also wrote the header for php as instructed in the codex. Will fill up the description later.
Step 3:(9:30) Added the Basic Hooks to add to the admin_menu, to display under the “users” menu. The plugin area shows:
“AuthorCode
0.1
Allows Author Specific code snippets insertion into the template By Anirudh Sanjeev.”
IT WORKS!!!!!!!!
Step 4:(9:40)
Have to detect the user name from the dashboard. If I get the name, I can store the snippets in the database. After searching for a while, found it here. Now to find the username, and display it in the admin panel. And after some more trial and error, a plugin that says “Howdy, username” on the menu.
Step 5: (9:45)
Now have to figure out how to store data. Here I have to now make a critical choice. I can either use the wp options system, which is simpler but might not work, or make my own table, but it’s gonna be harder and more difficult.
After some thinking, I decided to use wp_options. it’s gonna write hundreds of options using sprintf(”authorcode_%s_%d”,$user_login,$snippet_num);
And after some strugging and reading php manuals, it works perfectly. God bless wordpress.
Step 6: (9:58)
Now I have to write the whole interface, and allow upto 10 code snippets(for now), send it via postdata to the same plugin, and store and call.
Step 7: (10:32)
Finally, the plugin is beginning to take shape. A lot has been complete. A couple more hours of coding should do the trick. I’ll finish more tommorow and update regarding that.
0 Responses to “My First Wordpress Plugin”