public function __construct() { $this->algolia_registry = \Algolia\Core\Registry::getInstance(); if ($this->algolia_registry->validCredential) { $this->algolia_helper = new \Algolia\Core\AlgoliaHelper($this->algolia_registry->app_id, $this->algolia_registry->search_key, $this->algolia_registry->admin_key); } $this->query_replacer = new \Algolia\Core\QueryReplacer(); $this->theme_helper = new \Algolia\Core\ThemeHelper(); $this->indexer = new \Algolia\Core\Indexer(); add_action('admin_menu', array($this, 'add_admin_menu')); add_action('admin_post_update_account_info', array($this, 'admin_post_update_account_info')); add_action('admin_post_update_index_name', array($this, 'admin_post_update_index_name')); add_action('admin_post_update_indexable_types', array($this, 'admin_post_update_indexable_types')); add_action('admin_post_update_type_of_search', array($this, 'admin_post_update_type_of_search')); add_action('admin_post_update_extra_meta', array($this, 'admin_post_update_extra_meta')); add_action('admin_post_custom_ranking', array($this, 'admin_post_custom_ranking')); add_action('admin_post_update_searchable_attributes', array($this, 'admin_post_update_searchable_attributes')); add_action('admin_post_update_sortable_attributes', array($this, 'admin_post_update_sortable_attributes')); add_action('admin_post_reset_config_to_default', array($this, 'admin_post_reset_config_to_default')); add_action('admin_post_export_config', array($this, 'admin_post_export_config')); add_action('admin_post_update_advanced_settings', array($this, 'admin_post_update_advanced_settings')); add_action('pre_get_posts', array($this, 'pre_get_posts')); add_filter('the_posts', array($this, 'get_search_result_posts')); add_action('admin_post_reindex', array($this, 'admin_post_reindex')); add_action('admin_enqueue_scripts', array($this, 'admin_scripts')); add_action('wp_enqueue_scripts', array($this, 'scripts')); add_action('wp_footer', array($this, 'wp_footer')); }
public function __construct() { $this->algolia_registry = \Algolia\Core\Registry::getInstance(); if ($this->algolia_registry->validCredential) { $this->algolia_helper = new \Algolia\Core\AlgoliaHelper($this->algolia_registry->app_id, $this->algolia_registry->search_key, $this->algolia_registry->admin_key); } $this->wordpress_fetcher = new WordpressFetcher(); }
public function __construct($app_id, $search_key, $admin_key) { $this->algolia_client = new \AlgoliaSearch\Client($app_id, $admin_key); $this->algolia_registry = \Algolia\Core\Registry::getInstance(); $this->app_id = $app_id; $this->admin_key = $admin_key; $this->search_key = $search_key; }
public function __construct($app_id, $search_key, $admin_key) { if (function_exists('curl_version') == false) { return; } $this->algolia_client = new \AlgoliaSearch\Client($app_id, $admin_key); $this->algolia_registry = \Algolia\Core\Registry::getInstance(); $this->app_id = $app_id; $this->admin_key = $admin_key; $this->search_key = $search_key; }
public function __construct() { $this->algolia_registry = \Algolia\Core\Registry::getInstance(); if ($this->algolia_registry->validCredential == false) { return; } $this->algolia_helper = new \Algolia\Core\AlgoliaHelper($this->algolia_registry->app_id, $this->algolia_registry->search_key, $this->algolia_registry->admin_key); $this->indexer = new \Algolia\Core\Indexer(); if ($this->algolia_registry->validCredential) { add_action('before_delete_post', array($this, 'postDeleted')); add_action('transition_post_status', array($this, 'postUnpublished'), 10, 3); add_action('save_post', array($this, 'postUpdated'), 11, 3); add_action('edited_term_taxonomy', array($this, 'termTaxonomyUpdated'), 10, 2); add_action('created_term', array($this, 'termCreated'), 10, 3); add_action('delete_term', array($this, 'termDeleted'), 10, 4); } }
public function getPostObj($data) { $algolia_registry = \Algolia\Core\Registry::getInstance(); $obj = new \stdClass(); foreach ($this->contentFieldsNames as $key => $value) { $name = $value["label"]; $obj->{$name} = $this->cast($data->{$key}, $value["type"]); } $obj->author = get_the_author_meta('display_name', $data->post_author); $obj->author_first_name = get_the_author_meta('first_name', $data->post_author); $obj->author_last_name = get_the_author_meta('last_name', $data->post_author); $obj->author_login = get_the_author_meta('user_login', $data->post_author); $obj->permalink = get_permalink($data->ID); $this->getContent($data, $obj); unset($obj->excerpt); //$obj->excerpt = my_excerpt($data->post_content, get_the_excerpt()); $thumbnail_id = get_post_thumbnail_id($data->ID); if ($thumbnail_id) { $obj->featureImage = $this->getImage($thumbnail_id); } if ($algolia_registry->metas && isset($algolia_registry->metas[$data->post_type]) && is_array($algolia_registry->metas[$data->post_type])) { foreach (get_post_meta($data->ID) as $meta_key => $meta_value) { if (in_array($meta_key, array_keys($algolia_registry->metas[$data->post_type]))) { if ($algolia_registry->metas[$data->post_type][$meta_key]["indexable"]) { $obj->{$meta_key} = $this->try_cast($meta_value[0]); } } } } foreach (get_post_taxonomies($data->ID) as $tax) { $terms = wp_get_post_terms($data->ID, $tax); if (count($terms) <= 0) { continue; } if (isset($algolia_registry->metas['tax']) && isset($algolia_registry->metas['tax'][$tax])) { $obj->{$tax} = array_map(function ($obj) { return $obj->name; }, $terms); } } if (has_filter('prepare_algolia_record')) { $obj = apply_filters('prepare_algolia_record', $obj); } return (array) $obj; }
<?php $langDomain = "algolia"; $algolia_registry = \Algolia\Core\Registry::getInstance(); $template_helper = new Algolia\Core\TemplateHelper(); $current_template = $template_helper->get_current_template(); $move_icon_url = plugin_dir_url(__FILE__) . '../imgs/move.png'; $need_to_reindex = $algolia_registry->need_to_reindex; global $attributesToIndex; ?> <?php if (function_exists('curl_version') == false) { ?> <div> <h1>Algolia Search : Errors</h1> <ul> <li>You need to have <b>curl</b> and <b>php5-curl</b> installed</li> </ul> </div> <?php return; } ?> <div id="algolia-settings" class="wrap"> <a target="_blank" href="//algolia.com/dashboard" class="header-button" id="dashboard-link">Go to Algolia dashboard</a> <?php if ($algolia_registry->validCredential) {