/** * Read the ComicPress config. */ function read_comicpress_config($override_config = null) { global $wpmu_version; $method = null; if (is_array($override_config)) { $method = __("Unit Testing", 'comicpress-manager'); $this->properties = array_merge($this->properties, $override_config); } else { if (!empty($wpmu_version) && function_exists('cpm_wpmu_load_options')) { cpm_wpmu_load_options(); $method = __("WordPress Options", 'comicpress-manager'); } else { $current_theme_info = get_theme(get_current_theme()); if (isset($current_theme_info['Template Dir'])) { foreach (array("comicpress-config.php", "functions.php") as $possible_file) { $filepath = WP_CONTENT_DIR . $current_theme_info['Template Dir'] . '/' . $possible_file; if ($this->_f->file_exists($filepath)) { $this->config_filepath = $filepath; $file = $this->_f->file_get_contents($filepath); $variable_values = array(); foreach (array_keys($this->properties) as $variable) { if (preg_match("#\\\${$variable}\\ *\\=\\ *([^\\;]*)\\;#", $file, $matches) > 0) { $variable_values[$variable] = preg_replace('#"#', '', $matches[1]); } } $this->properties = array_merge($this->properties, $variable_values); $method = basename($filepath); $this->can_write_config = false; $perm_check_filename = $filepath . '-' . md5(rand()); if (@touch($perm_check_filename) === true) { $move_check_filename = $perm_check_filename . '-' . md5(rand()); if (@rename($perm_check_filename, $move_check_filename)) { @unlink($move_check_filename); $this->can_write_config = true; } else { @unlink($perm_check_filename); } } break; } } } } } $this->config_method = $method; }
/** * Read the ComicPress config from a file. */ function read_current_theme_comicpress_config() { global $cpm_config, $wpmu_version; if ($wpmu_version) { cpm_wpmu_load_options(); return __("WordPress Options", 'comicpress-manager'); } $current_theme_info = get_theme(get_current_theme()); $method = null; $config_json_file = ABSPATH . '/' . $current_theme_info['Template Dir'] . '/config.json'; // harmonious json_decode if (function_exists("json_decode")) { if (file_exists($config_json_file)) { $config = json_decode(file_get_contents($config_json_file), true); $cpm_config->properties = array_merge($cpm_config->properties, $config); $method = "config.json"; } } //harmonious_end if (is_null($method)) { if (!is_null($filepath = get_functions_php_filepath())) { read_comicpress_config_functions_php($filepath); $method = basename($filepath); } } return $method; }