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