protected function updateFiles() { Cli::pinfo("Update Files"); foreach (array("composer.json", "index.php", "setup") as $file) { Cli::pinfo(" * Update {$file}"); $content = file_get_contents(getcwd() . DIRECTORY_SEPARATOR . $file); foreach (Options::getAll() as $key => $val) { $content = str_replace("@{$key}@", $val, $content); } $content = str_replace("@DATE@", date("r"), $content); $gitignore = trim(file_get_contents($this->getDir() . DIRECTORY_SEPARATOR . "project" . DIRECTORY_SEPARATOR . ".gitignore")); $content = str_replace("@EXCLUDES@", "\"" . implode(explode("\n", $gitignore), "\", \"") . "\"", $content); file_put_contents(getcwd() . DIRECTORY_SEPARATOR . $file, $content); } }
/** * Plugin initialization callback. * * @global WP $wp * * @uses apply_filters() * @uses load_plugin_textdomain() * @uses load_textdomain() * @uses trailingslashit() */ public function init() { global $wp; $domain = static::SLUG; $locale = \apply_filters('plugin_locale', \get_locale(), 'wp-cas-server'); \load_textdomain($domain, \trailingslashit(WP_LANG_DIR) . $domain . '/' . $domain . '-' . $locale . '.mo'); \load_plugin_textdomain($domain, FALSE, basename(\plugin_dir_path(dirname(__FILE__))) . '/languages/'); if (!Options::getAll()) { Options::setDefaults(); } $wp->add_query_var(static::QUERY_VAR_ROUTE); $this->addRewriteRules(); }
/** * Validates and updates CAS server plugin settings. * * @param array $input Unvalidated input arguments when settings are updated. * * @return array Validated plugin settings to be saved in the database. * * @since 1.1.0 */ public function validateSettings($input) { $options = Options::getAll(); $options['attributes'] = (array) $input['attributes']; return $options; }
public function cf_options($keys = null) { if ($keys == null) { $keys = array(); foreach (Options::getAll() as $key => $val) { if (substr($key, -5) == "_PATH") { $keys[] = $key; } } } $options = array(); foreach (Options::getAll() as $key => $val) { if (in_array($key, $keys)) { $options[strtolower($key)] = $val; } } if (Session::Has(Session::rights_key)) { $options["rights"] = Session::Get(Session::rights_key); } else { $options["rights"] = array(); } if (Session::Has(AbstractLogin::userid)) { $options["user"] = Session::Get(AbstractLogin::userid); } else { $options["user"] = false; } foreach (Plugins::dispatchAll("cf_options") as $opt) { $options = array_merge($options, $opt); } echo json_encode($options); }