Skip to content

Instantly share code, notes, and snippets.

View rayrutjes's full-sized avatar
🎸

Raymond Rutjes rayrutjes

🎸
View GitHub Profile
@rayrutjes
rayrutjes / ais-wp.css
Created July 7, 2016 12:48
Some boilerplate to create an instantsearch.js search experience in your WordPress theme. This works in combination with the Algolia Search plugin for WordPress.
#ais-wrapper {
display: flex;
}
#ais-main {
padding: 1rem;
width: 100%;
}
@rayrutjes
rayrutjes / list-big-files.sh
Created April 24, 2018 07:05
List big files on your Mac
sudo find / -type f -size +100000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
@rayrutjes
rayrutjes / hide-instantsearch.php
Created March 12, 2018 15:06
Programatically hide instantsearch in Algolia plugin for WordPress
<?php
add_filter( 'algolia_should_override_search_with_instantsearch', function() {
return false;
} );
@rayrutjes
rayrutjes / replace-domain-wordpress-algolia-plugin.php
Created February 26, 2018 12:21
Replace domain in Algolia Search plugin for WordPress
<?php
/**
* @version 0.1.0
* Plugin Name: Replace domain in Algolia Search plugin for WordPress
*/
function custom_post_shared_attributes( array $shared_attributes ) {
$shared_attributes['permalink'] = str_replace( 'admin.rushlimbaugh.com', 'www.rushlimbaugh.com', $shared_attributes['permalink'] );
return $shared_attributes;
}
@rayrutjes
rayrutjes / algolia-woocommerce-filter-facets.php
Last active February 14, 2018 08:04
Filter displayed facets in Algolia plugin for WooCommerce
<?php
add_filter( 'algolia_wc_attributes_for_faceting', function( $attributes ) {
$only_ids = array(
15, // Main Style
13, // Main Color
49, // Sizes
23, // Brand
4, // Collection
22, // Material
@rayrutjes
rayrutjes / algolia-woocommerce-instantsearch.php
Created January 31, 2018 19:01
Display WooCommerce InstantSearch on home page Algolia
<?php
// Inject instantsearch.js on every page regardless of backend config.
add_filter( 'algolia_wc_should_display_instantsearch', '__return_true' );
// This will make sure the search is displayed on load. Oterwise it waits for the query to change to be displayed.
add_filter( 'algolia_config', function( array $config ) {
$config['woocommerce']['replace_page'] = true;
@rayrutjes
rayrutjes / algolia-custom-post-types.php
Created January 31, 2018 09:36
Add custom post type to dedicated WordPress search results page for Algolia plugin for WordPress
<?php
// See: https://github.com/algolia/algoliasearch-wordpress/blob/master/includes/class-algolia-plugin.php#L181
// To be added to the functions.php of your active theme for example.
add_filter( 'algolia_searchable_post_types', function( array $post_types ) {
$post_types[] = 'my_custom_post_type';
return $post_types;
} );
@rayrutjes
rayrutjes / display-instantsearch-all-pages.php
Created January 26, 2018 09:03
Display instantsearch on all pages in Algolia WooCommerce plugin
<?php
add_filter( 'algolia_wc_should_display_instantsearch', function( $should_display ) {
// If configuration already considers it should be shawn, show it.
if ( $should_display ) {
return true;
}
// Detect the current page and only return true when you want instantsearch.js to be injected.
if ( is_shop() ) {
@rayrutjes
rayrutjes / custom-avatar.php
Created January 15, 2018 11:30
Custom avatar in Algolia plugin for WordPress
<?php
/**
* Plugin Name: Customize data pushed to Algolia.
*/
/**
* @param int $user_id
* @param string $fallback_avatar_url
*
* @return string
@rayrutjes
rayrutjes / customize-algolia-autocomplete-labels.php
Created January 3, 2018 14:17
Algolia WordPress customize autocomplete header labels for use with translation plugin
<?php
add_filter( 'algolia_autocomplete_config', function ( $config ) {
// echo '<pre>';
// var_dump( $config );
// echo '</pre>';
foreach ( $config as &$index ) {
// Adjust and adapt according to your needs.
if ( $index['index_id'] === 'posts_post' ) {