forked from NateWr/simple-admin-pages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple-admin-pages.php
52 lines (44 loc) · 1.38 KB
/
simple-admin-pages.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* Simple Admin Pages
*
* This is a very small utility library to easily add new admin pages to the
* WordPress admin interface. It simply collects WordPress' useful Settings API
* into reuseable classes.
*
* Created by Nate Wright
*
*
* @since 1.0
* @package Simple Admin Pages
* @license GNU GPL 2 or later
*/
/**
* Always load the library files attached to this copy of SAP
*
* This fixes a compatibility bug if two versions of the library are being
* loaded by different plugins/themes. However, versions prior to 2.0 do not
* include this and can cause compatibility issues.
*/
require_once( 'classes/Library.class.php' );
/**
* Initialize the appropriate version of the libary.
*
* This function should remain backwards compatible at all times, so that the
* initialization function from version 1.0 will still be able to initialize
* the library appropriately for version 2.0. This way, if two plugins exist
* with different versions, the plugin creator will still be able to initialize
* their library.
*
* @since 1.0
*/
if ( !function_exists( 'sap_initialize_library' ) ) {
function sap_initialize_library( $args = array() ) {
// Exit early if no version was provided
if ( !isset( $args['version'] ) ) {
return null;
}
$lib_class_name = 'sapLibrary_' . str_replace( '.', '_', $args['version'] );
return new $lib_class_name( $args );
}
}