/** * Hooked on admin_init. Registers the options and enqueues admin style and javascript. */ public static function actionAdminInit() { wp_enqueue_style('elasticsearch-indexer', ESI_URL . 'assets/admin/style.css'); wp_enqueue_script('elasticsearch-indexer', ESI_URL . 'assets/admin/script.js', ['jquery']); foreach (Config::load('defaults') as $key => $value) { register_setting('esi_options_group', Config::OPTION_PREFIX . $key); } }
/** * Delete existing index, create new index and add mappings. */ protected function flush() { $indexName = $this->getIndexName(); if ($this->indices()->exists(['index' => $indexName])) { $this->indices()->delete(['index' => $indexName]); } $this->indices()->create(['index' => $indexName, 'body' => ['settings' => Config::load('settings'), 'mappings' => Config::load('mappings')]]); }