Skip to content

Instantly share code, notes, and snippets.

View rayrutjes's full-sized avatar
🎸

Raymond Rutjes rayrutjes

🎸
View GitHub Profile
@rayrutjes
rayrutjes / disable-wp-content-filter.php
Created September 20, 2017 18:17
Display wordpress content filter
<?php
// https://github.com/algolia/algoliasearch-wordpress/blob/master/includes/indices/class-algolia-searchable-posts-index.php#L82
// Replace
$post_content = apply_filters( 'the_content', $post->post_content );
// With
$post_content = $post->post_content;
// Same change on this file
// https://github.com/algolia/algoliasearch-wordpress/blob/master/includes/indices/class-algolia-posts-index.php#L92
// Replace
@rayrutjes
rayrutjes / remove-attribute.php
Last active September 20, 2017 12:06
WordPress remove attribute from indexing
<?php
add_filter( 'algolia_post_shared_attributes', 'exclude_event_attributes', 10, 2 );
function exclude_event_attributes(array $shared_attributes, WP_Post $post) {
unset($shared_attributes['comment_count']);
unset($shared_attributes['record_index']);
unset($shared_attributes['is_sticky']);
unset($shared_attributes['post_mime_type']);
unset($shared_attributes['menu_order']);
@rayrutjes
rayrutjes / 2-v1-vue-instantsearch.js
Created August 22, 2017 12:25
2-v1-vue-instantsearch.js
import Vue from 'vue';
import InstantSearch from 'vue-instantsearch';
Vue.use(InstantSearch);
@rayrutjes
rayrutjes / aggregate-results.vue
Created August 16, 2017 16:28
Aggregate results of multiple indices in Vue InstantSearch
<template>
<div>
<ais-index :search-store="searchStore1"></ais-index>
<ais-index :search-store="searchStore2"></ais-index>
<your-map-component :results="combinedResults"></your-map-component>
</div>
</template>
<script>
@rayrutjes
rayrutjes / refinement-list-inline-template.html
Created August 7, 2017 10:17
Vue InstantSearch refinement-list inline template
<ais-refinement-list attribute-name="Source_type" inline-template>
<div v-if="show">
<template v-for="facet in facetValues" :key="facet.name">
<div class="input-checkbox">
<input
type="checkbox"
v-model="facet.isRefined"
@change="toggleRefinement(facet)"
:value="facet.name"
/>
@rayrutjes
rayrutjes / hide-results.vue
Last active August 4, 2017 20:50
Hide results if query is empty - Vue InstantSearch
<template>
<ais-index :search-store="searchStore">
<ais-input></ais-input>
<ais-results v-show="searchStore.query.length > 0"></ais-results>
</ais-index>
</template>
<script>
import { createFromAlgoliaCredentials } from 'vue-instantsearch';
<?php
namespace Mamdauka\WpQuerySpeed\Command;
use WP_CLI;
use WP_CLI\Utils;
use WP_CLI_Command;
use WP_Query;
use Symfony\Component\Stopwatch\Stopwatch;
@rayrutjes
rayrutjes / import-wordpress-posts.php
Created May 30, 2017 21:54
Import WordPress posts with images categories and users
<?php
if (php_sapi_name() !== 'cli') {
die("Meant to be run from command line");
}
function find_wordpress_base_path()
{
$dir = dirname(__FILE__);
do {
<?php
// To be added to the functions.php file of your active theme.
function vm_post_shared_attributes(array $shared_attributes, WP_Post $post)
{
if ($shared_attributes['post_type_label'] === 'Posts') {
$shared_attributes['post_type_label'] = 'Videos';
}
return $shared_attributes;
}
@rayrutjes
rayrutjes / title-anchors.css
Created March 27, 2017 08:22
Title anchors
.anchor {
float: left;
padding-right: 4px;
margin-left: -20px;
display: none;
}
h1:hover .anchor, h2:hover .anchor, h3:hover .anchor {
display: inline;
}