NateJacobs / Brickset-API

WordPress Plugin: Display your favorite LEGO® set information on your website using the Brickset API. This plugin is an implementation of the Brickset Webservice. It includes methods to get LEGO® set and theme data from Brickset as well as pre-formated methods to display set data. The set data requested is cached daily to reduce HTTP requests and page load time. Please visit Brickset.com for more information on the webservice. You can obtain an API key from Brickset.
GNU General Public License v2.0
17 stars 2 forks source link

Brickset API

This version is outdated. The Brickset API is now on version 2.0 and this code will no longer work.

Version 1.4

Works with WordPress v3.5+ Works with Brickset API v2

Display your favorite LEGO® set information on your website using the Brickset API.

Description

This plugin is an implementation of the Brickset Webservice. It includes methods to get LEGO® set and theme data from Brickset as well as pre-formated methods to display set data. The set data requested is cached daily to reduce HTTP requests and page load time. Please visit Brickset for more information on the webservice. You can obtain an API key from Brickset.

The main development is all happening on GitHub.

This is not an official Brickset.com plugin. LEGO® is a trademark of the LEGO Group of companies which does not sponsor, authorize or endorse this plugin.

Oembed

You can paste a Brickset set or theme url into your post or page. Once you publish the post or page information about the set or theme will be displayed. Two example URLs are below.

Template Tags

The plugin has numerous template tags you are able to use in your theme. They are listed below with a short description.

Shortcode

The plugin has a shortcode you may use in your posts and pages to display information about a set or sets.

Widgets

The plugin has four widgets you can activate in your theme. The first displays a list of all themes on Brickset with a link to browse each theme on Brickset.com and the second to display the details about a specific set. The third allows you to show off the total count of your minifigs. The last widget displays a count of sets produced in each year for a given theme.

Advanced Use

This example shows how to get the data about a specific set. You can find the developer docs here.

  1. Instantiate the class.

    $brickset = new BricksetAPISearch();
  2. Pass a set number to the get_by_number method.

    $set_data = $brickset->get_by_number( '8014' );
  3. Test for an error

    if( is_wp_error( $set_data ) {
    echo $set_data->get_error_message;
    }
  4. Display the results how you like. This will display the set's theme.

    else {
    echo $set_data->theme;
    }

Road Map

  1. Template tags to display sets specific to a user.
  2. Caching of images

You can follow all the open feature requests and enhancements on GitHub.

Installation

  1. Upload the entire brickset-api folder to the wp-content/plugins/ directory of your WordPress installation or download from the Plugin Repository
  2. Activate the plugin through the Plugins menu in WordPress
  3. Add your Brickset.com API key to the Brickset settings page which can be found as a submenu under the Settings menu
  4. Either add a Brickset link (url) to a set or theme in a post or page, or add a template tag to a theme file, or for advanced use instantiate the class and create your own display method.

Frequently Asked Questions

Can I add sets to my set list on Brickset with this plugin?

Yes you can, but it requires writing custom code using the API functions of the plugin.

Does this plugin require an API Key from Brickset

To display more than twenty sets from a search query an API key is required. You can obtain one by contacting Brickset on this page.

Screenshots

1. Individual Set Display

Individual Set Display

2. Years theme is available

Years theme is available

3. Sets in space theme

Sets in space theme

Changelog

Version 1.4.0

Version 1.3

Version 1.2

Version 1.1

Version 1.0

Version 0.3

Version 0.2

Version 0.1

License [GPLv2 or later]((http://www.gnu.org/licenses/gpl-2.0.html)