public static function load_settings($just_load_settings = FALSE) { if (self::$options === NULL) { // Load settings from db if (!(self::$options = get_option(self::OPTIONS))) { self::$options = CrayonSettings::get_defaults_array(); update_option(self::OPTIONS, self::$options); } // Initialise default global settings and update them from db CrayonGlobalSettings::set(self::$options); } if (!self::$is_fully_loaded && !$just_load_settings) { // Load everything else as well // For local file loading // This is used to decouple WP functions from internal Crayon classes CrayonGlobalSettings::site_url(home_url()); CrayonGlobalSettings::site_path(ABSPATH); CrayonGlobalSettings::plugin_path(plugins_url('', __FILE__)); $upload = wp_upload_dir(); CrayonLog::debug($upload, "WP UPLOAD FUNCTION"); CrayonGlobalSettings::upload_path(CrayonUtil::path_slash($upload['basedir']) . CRAYON_DIR); CrayonGlobalSettings::upload_url($upload['baseurl'] . '/' . CRAYON_DIR); CrayonLog::debug(CrayonGlobalSettings::upload_path(), "UPLOAD PATH"); CrayonGlobalSettings::set_mkdir('wp_mkdir_p'); // Load all available languages and themes CrayonResources::langs()->load(); CrayonResources::themes()->load(); // Ensure all missing settings in db are replaced by default values $changed = FALSE; foreach (CrayonSettings::get_defaults_array() as $name => $value) { // Add missing settings if (!array_key_exists($name, self::$options)) { self::$options[$name] = $value; $changed = TRUE; } } // A setting was missing, update options if ($changed) { update_option(self::OPTIONS, self::$options); } self::$is_fully_loaded = TRUE; } }