Mais conteúdo relacionado
Semelhante a How To Write a WordPress Plugin (20)
Mais de Andy Stratton (10)
How To Write a WordPress Plugin
- 1. How to Write a
WordPress Plugin
Baltimore WordPress Meetup • September 19,
2011
- 2. What is a plugin?
Written in PHP
Adds functionality
without affecting core
code
Plugin API
- 4. Actions
Hey, WP! I’d like to do this
when you do that...
Calls a function that performs an
action, possibly with some data
given by WP
- 7. Filters
Hey, WP! I’d like to change a
value that you’re returning/
using...
Calls a function that returns a final
- 11. Plugin Information
<?php
/*
Plugin Name: My Simple Plugin
Plugin URI: http://theandystratton.com/my-plugin
Description: Does something awesome.
Version: 1.0
Author: theandystratton
Author URI: http://theandystratton.com
License: GPL2
*/
- 13. Don’t Just Drop
Code
WordPress includes plugins
while initializing
Coding without hooking into
actions/filters = explosion
- 16. Some Code
Hey WP! When you’re
processing standard content,
call this function!
- 20. Archives, Listings,
etc.
Oops. I mean, I only want it
to add my signature to the
single post, not listings/
archives.
- 21. Archives, Listings,
etc.
What do you want to do
now?
Filter the content of all posts
and append my signature
- 22. IF we’re on a single post page,
THEN add my signature.
- 24. Post Type Content
Oops. I have a custom post
type called “Products,” and
it’s adding my signature to
those, too.
- 25. IF we’re on a single blog post
page, THEN add my signature.
- 28. Using Objects
Avoid tons of
prefixed functions
Use a prefixed class to hold
all your actions/filters
- 31. Plugins Do Way
More
Custom Post Types
Shortcodes
Metaboxes and metadata
management
- 32. Plugins Do Way
More
Settings Pages
Settings Fields
Incorporate Internationalization
- 33. Plugins Do Way
More
Redirect requests
Modify Rewrite Rules
Emulate CRON jobs (wp-
cron.php)
- 35. Get in the
Repository
Submit your plugin code
http://wordpress.org/extend/plugins/
about/
http://wordpress.org/extend/plugins/
about/faq/
- 36. Get in the
Repository
Readme.txt
http://wordpress.org/extend/plugins/
about/readme.txt
- 37. Get in the
Repository
Subversion access &
management
Support URL?
Update within 2 years or hide
- 38. More Resources
“Writing a Plugin”
http://codex.wordpress.org/
Writing_a_Plugin
“WordPress Coding
Standards”
http://codex.wordpress.org/
WordPress_Coding_Standards
Notas do Editor
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n