Skip to content
scribu edited this page Jan 17, 2013 · 31 revisions

scbFramework is a collection of classes that speed up WordPress development.

Classes

Loading

There are two "official" ways to load the scbFramework files:

Loading from a plugin

  1. Move the scbFramework folder to wp-content/plugins/my-plugin/scb.

Then, just require the load.php file:

<?php
// Plugin Name: My plugin

require dirname( __FILE__ ) . '/scb/load.php';

function my_plugin_init() {
  $option = new scbOptions( 'my_plugin' );  // OK

  require_once dirname(__FILE__) . '/plugin-functions.php'; // using require() can cause activation errors
}

scb_init( 'my_plugin_init' );

Instantiating a class before the my_plugin_init() function runs will result in a "class does not exist" fatal error.

Instantiating a class after the my_plugin_init() function runs might result in strange malfunctions, as some of the add_action() calls from the class might become too late.

Loading from a "must-use" plugin

This method is recommended when you plan to use scbFramework on a site that you control.

  1. Move the scbFramework folder to wp-content/mu-plugins/scb (create the directories as needed).
  2. Copy the scb-load.php file into wp-content/mu-plugins/.

Now, all the classes are available to all plugins and themes. For example, in your theme's functions.php file you can write:

<?php

$my_theme_options = new scbOptions( 'my_theme_options' );

There's also an example plugin on WordPress.org.

Clone this wiki locally