Skip to content

Instantly share code, notes, and snippets.

@bchiang7
Created March 26, 2020 21:42
Show Gist options
  • Save bchiang7/f0eb94b297bae5108426e2c6c00c731a to your computer and use it in GitHub Desktop.
Save bchiang7/f0eb94b297bae5108426e2c6c00c731a to your computer and use it in GitHub Desktop.
<?php
public function set_config($args, $assoc_args) {
global $algolia;
$canonical_index_name = apply_filters('algolia_index_name', 'global_search');
$index = $algolia->initIndex($canonical_index_name);
// Set index settings if '--settings' flag exists
if (isset($assoc_args['settings'])) {
$settings = (array) apply_filters('algolia_get_settings', $index_name, []);
if ($settings) {
$index->setSettings($settings);
WP_CLI::success('Pushed settings to '.$index->getIndexName());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment