css
5 years ago
fonts
5 years ago
img
9 years ago
inc
5 years ago
js
5 years ago
view
5 years ago
core.php
5 years ago
core.php
122 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Plugin Name: WPMU Dev code library |
| 4 | * Plugin URI: http://premium.wpmudev.org/ |
| 5 | * Description: Framework to support creating WordPress plugins and themes. |
| 6 | * Version: 3.1.1 |
| 7 | * Author: WPMU DEV |
| 8 | * Author URI: http://premium.wpmudev.org/ |
| 9 | * Textdomain: wpmu-lib |
| 10 | * |
| 11 | * ============================================================================ |
| 12 | * |
| 13 | * Constants for wp-config.php |
| 14 | * |
| 15 | * Load the unminified JS/CSS files |
| 16 | * Default: false |
| 17 | * define( 'WDEV_UNMINIFIED', true ); |
| 18 | * |
| 19 | * Activate lib3()->debug->dump() without having to enable WP_DEBUG |
| 20 | * Default: Same as WP_DEBUG |
| 21 | * define( 'WDEV_DEBUG', true ); |
| 22 | * |
| 23 | * Disable lib3()->debug->dump() for Ajax requests |
| 24 | * Default: Same as WDEV_DEBUG |
| 25 | * define( 'WDEV_AJAX_DEBUG', false ); |
| 26 | * |
| 27 | * Modify or disable the P3P HTTP header for all responses. |
| 28 | * Default: 'CP="NOI"'. |
| 29 | * define( 'WDEV_SEND_P3P', false ) // Disable P3P |
| 30 | * define( 'WDEV_SEND_P3P', 'CP="CAO OUR"' ) // Overwrite default P3P header |
| 31 | */ |
| 32 | |
| 33 | $version = '3.1.1'; |
| 34 | |
| 35 | if ( ! function_exists( 'lib3' ) ) { |
| 36 | /** |
| 37 | * This is a shortcut function to access the latest TheLib_Core object. |
| 38 | * |
| 39 | * The shortcut function is called `lib3` because it is incompatible with |
| 40 | * the old WDev() function. The number "3" reflects the main version of this |
| 41 | * module. |
| 42 | * |
| 43 | * The main version is only increased when backwards compatibility fails! |
| 44 | * |
| 45 | * Usage: |
| 46 | * lib3()->ui->admin_message(); |
| 47 | */ |
| 48 | function lib3() { |
| 49 | return TheLib3_Wrap::get_obj(); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | // ============================================================================ |
| 54 | // Internal module definition: |
| 55 | |
| 56 | // Define the absolute paths to all class files of this submodule. |
| 57 | $dirname = dirname( __FILE__ ) . '/inc/'; |
| 58 | $files = array( |
| 59 | 'TheLib' => $dirname . 'class-thelib.php', |
| 60 | 'TheLib_Core' => $dirname . 'class-thelib-core.php', |
| 61 | 'TheLib_Array' => $dirname . 'class-thelib-array.php', |
| 62 | 'TheLib_Debug' => $dirname . 'class-thelib-debug.php', |
| 63 | 'TheLib_Html' => $dirname . 'class-thelib-html.php', |
| 64 | 'TheLib_Net' => $dirname . 'class-thelib-net.php', |
| 65 | 'TheLib_Session' => $dirname . 'class-thelib-session.php', |
| 66 | 'TheLib_Updates' => $dirname . 'class-thelib-updates.php', |
| 67 | 'TheLib_Ui' => $dirname . 'class-thelib-ui.php', |
| 68 | ); |
| 69 | |
| 70 | if ( ! class_exists( 'TheLib3_Wrap' ) ) { |
| 71 | /** |
| 72 | * The wrapper class is used to handle situations when some plugins include |
| 73 | * different versions of TheLib. |
| 74 | * |
| 75 | * TheLib3_Wrap will always keep the latest version of TheLib for later usage. |
| 76 | * |
| 77 | * @internal Use function `lib3()` instead! |
| 78 | */ |
| 79 | class TheLib3_Wrap { |
| 80 | static protected $version = '0.0.0'; |
| 81 | static protected $files = array(); |
| 82 | static protected $object = null; |
| 83 | |
| 84 | /** |
| 85 | * Store the module files if they are the highest module-version |
| 86 | */ |
| 87 | static public function set_version( $version, $files ) { |
| 88 | if ( null !== self::$object ) { return; } |
| 89 | if ( version_compare( $version, self::$version, '>' ) ) { |
| 90 | self::$version = $version; |
| 91 | self::$files = $files; |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Return version. |
| 97 | * |
| 98 | * @since 3.0.6 |
| 99 | */ |
| 100 | static public function get_version() { |
| 101 | return self::$version; |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Return the module object. |
| 106 | */ |
| 107 | static public function get_obj() { |
| 108 | if ( null === self::$object ) { |
| 109 | foreach ( self::$files as $class_name => $class_file ) { |
| 110 | if ( ! class_exists( $class_name ) && file_exists( $class_file ) ) { |
| 111 | require_once $class_file; |
| 112 | } |
| 113 | } |
| 114 | self::$object = new TheLib_Core(); |
| 115 | } |
| 116 | return self::$object; |
| 117 | } |
| 118 | } // End: TheLib3_Wrap |
| 119 | } |
| 120 | // Stores the lib-directory if it contains the highest version files. |
| 121 | TheLib3_Wrap::set_version( $version, $files ); |
| 122 |