> PostTypeBuilder wordpress plugin resources analysis

PostTypeBuilder wordpress plugin resources analysis

Download This Plugin
Download Elegant Themes
Name PostTypeBuilder
Version 0.5
Author Björn Ali Göransson
Rating 0
Last updated 2012-01-23 02:14:00
Downloads
549
Download Plugins Speed Test plugin for Wordpress

Home page

Delta: 0%

Post page

Delta: 0%
PostTypeBuilder plugin has no negative impact on PageSpeed score.

Home page PageSpeed score has been degraded by 0%, while Post page PageSpeed score has been degraded by 0%

PostTypeBuilder plugin added 23 bytes of resources to the Home page and 27 bytes of resources to the sample Post page.

PostTypeBuilder plugin added 0 new host(s) to the Home page and 0 new host(s) to the sample Post page.

Great! PostTypeBuilder plugin ads no tables to your Wordpress blog database.

PostTypeBuilder is an Object Relational Mapper connecting directly into the Wordpress engine, and provides handy scaffolding through the Wordpress GUI, as well as data querying similar to LINQ and ActiveRecord (Book::find()->where(...)).

class Book extends Entity{
    /** @Property */
    public $number_of_pages;
}
while(have_posts()){
    the_post(); $book = new Book($post);
    
    echo "<dt>" . $book->post_title . "</dt>";
    echo "<dd>" . $book->number_of_pages . "</dd>";
}

Included is the Addendum library to support @annotations.

This plugin saves no information on your system (no database tables, no temporary files). All information is supplied by you in your class files.

See Other notes for more info

Register classes

Any classes in wp-content/classes, where the filename (like class_name.php) corresponds to the classname (like ClassName), will be registered as a Wordpress Custom Post Type.

Following example needs to be defined in wp-content/classes/book.php, and results in a registered post type being shown in the admin UI (but not publicly queryable):

namespace MyEntities;
use \PostTypeBuilder\Entity;

class Book extends Entity{
}

See Other notes for more info

Define properties

Any class properties prefixed by the annotational comment /** @Property */ will be registered as Wordpress metadata, and form fields will appear in the edit/create screen of the post type corresponding to the property type.

Following example, building on the previous Book example class, will display a text form field in the edit/create post screen:

namespace MyEntities;
use \PostTypeBuilder\Entity;

class Book extends Entity{
    /** @Property */
    public $number_of_pages;
}

To enable the property to carry multiple values, use the = array() assignment:

/** @Property */
public $authors = array();

See Other notes for more info

Find entities

You can load entities in three ways.

(1) By post ID:

$book = new Book(21);

(2) By post object (useful in the loop):

global $post;

$book = new Book($post);

(3) By query:

$books = Book::find()->where("pages > (NUMERIC)", 10);

foreach($books as $book){ ... }

(Note that the query is executed lazily - ie. at the foreach statement)

Following code shows how to manipulate your entities:

$book = new Book();
$book->post_title = "Foo";
$book->save();

(Both post_object members and class properties are accessed in a unified way, but class properties have precedence)

See Other notes for more info

Extend the functionality

The plugin is designed to be extensible, so you can override form field generation for your classes, text representations (by overriding __toString), add your own property types, their form field generation, their text representation, you can hook into save events (and more...).

Screenshots

Resources added by plugin to Home page/Post page in kB
Total size of resources for Home page/Post page in kB
Random Theme Tests
r2d2 screenshot

r2d2

by: RDall

9755
100%
FAM screenshot

FAM

by: diamondsdesigners

9962
0%