-
Notifications
You must be signed in to change notification settings - Fork 55
Home
scbFramework is a collection of classes that speed up WordPress development.
For an example, see https://github.com/scribu/wp-scb-framework-example
- scbForms - form generator
- scbOptions - option handling
- scbAdminPage - admin page creation
- scbBoxesPage - admin page with meta boxes
- scbPostMetabox - create metaboxes on the post editing page
- scbWidget - integration betwee WP_Widget and scbForms
- scbCron - Object-oriented wp-cron handling
- scbTable - database table creation
- scbHooks - automatic filter binding
- scbUtil - useful functions
- scbLoad - loads all the rest of the classes
There are two "official" ways to load the scbFramework files:
- 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 later than the 'plugins_loaded'
hook might result in malfunctions, since scb classes make various add_action()
calls themselves.
This method is recommended when you plan to use scbFramework on a site that you control.
- Move the scbFramework folder to
wp-content/mu-plugins/scb
(create the directories as needed). - Create a
wp-content/mu-plugins/scb-load.php
file with following contents:
<?php
define( 'SCB_LOAD_MU', dirname( __FILE__ ) . '/scb/' );
foreach ( array(
'scbUtil', 'scbOptions', 'scbForms', 'scbTable',
'scbWidget', 'scbAdminPage', 'scbBoxesPage', 'scbPostMetabox',
'scbCron', 'scbHooks',
) as $className ) {
include SCB_LOAD_MU . substr( $className, 3 ) . '.php';
}
function scb_init( $callback = '' ) {
if ( $callback )
call_user_func( $callback );
}
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.