19
Group Extension API buddypress.org/developers/apeatling @apeatling Andy Peatling BuddyPress

BuddyPress Groups API

Embed Size (px)

DESCRIPTION

Creating killer group extensions with BuddyPress.

Citation preview

Page 1: BuddyPress Groups API

Group Extension API

buddypress.org/developers/apeatling@apeatling

Andy Peatling

BuddyPress

Page 2: BuddyPress Groups API

What’s API?Are People Interested

Angry People Inc.

All Peanuts InsideAnother Pointless Idea

Application Programming Interface

Page 3: BuddyPress Groups API

AbstractionIt’s all about

Page 4: BuddyPress Groups API

Application

Me (developer)

Writing code without an API

When the app changes, my code breaks!

More complex and scattered code

Usually quite “hacky”

Page 5: BuddyPress Groups API

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

Page 6: BuddyPress Groups 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...

Page 7: BuddyPress Groups API

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.

Page 8: BuddyPress Groups API

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.

Page 9: BuddyPress Groups API

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. :)

Page 10: BuddyPress Groups API

The WordPress API is Everywhere

get_posts()

get_usermeta()

wp_authenticate()

WP_Widget

add_action() add_filter()

update_usermeta()current_user_can()

Page 11: BuddyPress Groups API

BuddyPress Group Extension APIMaking it very simple to build new

custom group features

Page 12: BuddyPress Groups API
Page 13: BuddyPress Groups API
Page 14: BuddyPress Groups API
Page 15: BuddyPress Groups API
Page 16: BuddyPress Groups API
Page 17: BuddyPress Groups API
Page 18: BuddyPress Groups API

Let’s Build a Twitter ExtensionLive Demo... gulp.

Page 19: BuddyPress Groups API

Thank You!

http://codex.buddypress.org/developer-docs/group-extension-api/

Submit your group extensions to the WordPress plugin repo tagged with “BuddyPress”.