Upload
apeatling
View
5.935
Download
1
Embed Size (px)
DESCRIPTION
Creating killer group extensions with BuddyPress.
Citation preview
Group Extension API
buddypress.org/developers/apeatling@apeatling
Andy Peatling
BuddyPress
What’s API?Are People Interested
Angry People Inc.
All Peanuts InsideAnother Pointless Idea
Application Programming Interface
AbstractionIt’s all about
Application
Me (developer)
Writing code without an API
When the app changes, my code breaks!
More complex and scattered code
Usually quite “hacky”
Application
Me (developer)
Writing code using an API
When the app changes, the API takescare of it, your code doesn’t break!
Simple and standardized code
Lower barrier for entry
API
A Real World Example
SELECT ID FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 20
Fetch posts in WordPress without an API
Work out the query you need, check the database?
foreach ( (array) $posts as $post ) ....
Loop the results manually
wp_esc() ... wp_filter_kses() ??
What about security? Oh dear...
A Real World ExampleA Real World ExampleFetch posts in WordPress without an API
If the database schema changes in a new version of WordPress, your code breaks.
If the post fields change in a new version of WordPress,your code knows nothing about them.
Your code is hacker fodder.
A Real World ExampleA Real World ExampleFetch posts in WordPress using the API
get_posts( ‘numberposts=20’ );
Fetch the posts you need, who cares about the database?
<?php if ( have_posts() ) : while ( have_posts() ) : the_post();
Loop the results using the built in WordPress loop
the_content(); the_title(); the_tags();
Security? No worries.
A Real World ExampleA Real World ExampleFetch posts in WordPress using the API
No need to worry about database changes, get_posts() will update in new versions of WordPress.
If new post fields are available, you can use them in your code using new template tags.
Your code is safe.... hopefully. :)
The WordPress API is Everywhere
get_posts()
get_usermeta()
wp_authenticate()
WP_Widget
add_action() add_filter()
update_usermeta()current_user_can()
BuddyPress Group Extension APIMaking it very simple to build new
custom group features
Let’s Build a Twitter ExtensionLive Demo... gulp.
Thank You!
http://codex.buddypress.org/developer-docs/group-extension-api/
Submit your group extensions to the WordPress plugin repo tagged with “BuddyPress”.