Skip to content

Instantly share code, notes, and snippets.

Jon Christopher jchristopher

Block or report user

Report or block jchristopher

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View bundler.js
const Bundler = require('parcel-bundler');
const Path = require('path');
const file = Path.join(__dirname, './src/main.js');
const options = {
outDir: Path.join(__dirname, './dist'),
outFile: 'bundle.min.js',
watch: true,
cache: false,
@jchristopher
jchristopher / functions.php
Created Sep 5, 2019
Tell SearchWP to persist Extra Metadata
View functions.php
<?php
add_filter( 'searchwp_persist_extra_metadata', '__return_true' );
@jchristopher
jchristopher / functions.php
Created Sep 4, 2019
Tell SearchWP to index term names from ACF (Advanced Custom Fields) Taxonomy fields
View functions.php
<?php
// Tell SearchWP to index term names from ACF (Advanced Custom Fields) Taxonomy fields.
add_filter( 'searchwp_custom_fields', function( $meta_value, $meta_key, $the_post ) {
$acf_taxonomy_field_names = array( 'mytaxfield1', 'mytaxfield2' );
if ( ! in_array( $meta_key, $acf_taxonomy_field_names ) ) {
return $meta_value;
}
@jchristopher
jchristopher / gist:9baf1f26d1aab71a42cd
Last active Sep 4, 2019
Customize the SearchWP Live Search default config, and add your own
View gist:9baf1f26d1aab71a42cd
<?php
function my_searchwp_live_search_configs( $configs ) {
// override some defaults
$configs['default'] = array(
'engine' => 'default', // search engine to use (if SearchWP is available)
'input' => array(
'delay' => 400, // wait 500ms before triggering a search
'min_chars' => 5, // wait for at least 3 characters before triggering a search
),
@jchristopher
jchristopher / gist:3d9fe252561efa9aa6c2
Last active Sep 4, 2019
The default configurations array for SearchWP Live Search
View gist:3d9fe252561efa9aa6c2
<?php
$configs = array(
'default' => array( // 'default' config
'engine' => 'default', // search engine to use (if SearchWP is available)
'input' => array(
'delay' => 500, // wait 500ms before triggering a search
'min_chars' => 3, // wait for at least 3 characters before triggering a search
),
'parent_el' => 'body', // selector of the parent element for the results container
View spinner.css
@keyframes searchwp-spinner-line-fade-quick {
0%, 39%, 100% {
opacity: 0.25;
}
40% {
opacity: 1;
}
}
View phpunit.sh
wp-content/plugins/myplugin$ phpunit
Installing...
Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
Not running ajax tests. To execute these, use --group ajax.
Not running ms-files tests. To execute these, use --group ms-files.
Not running external-http tests. To execute these, use --group external-http.
PHPUnit 7.5.15 by Sebastian Bergmann and contributors.
...R%
wp-content/plugins/myplugin$
@jchristopher
jchristopher / gist:fc1d461bd82b40e31290
Last active Aug 30, 2019
Tell SearchWP to extract PDF contents of a file uploaded to an ACF file upload field and store that content with the post itself as custom metadata, not the Media entry
View gist:fc1d461bd82b40e31290
<?php
/**
* Extract PDF content from a file uploaded via ACF File field (where
* the actual data stored is only the Media ID) and store PDF
* content as SearchWP 'extra' metadata so it can be included in
* searches and attributed to the post itself, not the Media entry
*/
class My_SearchWP_Customizations {
@jchristopher
jchristopher / functions.php
Last active Aug 30, 2019
Add support for Groups to SearchWP
View functions.php
<?php
function my_searchwp_where( $where, $engine ) {
global $wp_query;
if ( class_exists( 'Groups_Post_Access' ) ) {
$where .= ' ' . Groups_Post_Access::posts_where( '', $wp_query );
}
return $where;
View functions.php
<?php
// this snippet is based on SearchWP's sample Supplemental Search Engine results template found here:
// https://searchwp.com/docs/configuration/#supplemental
// **************************** NOTE ****************************
// this snippet is just a portion of your search results template
// **************************** NOTE ****************************
You can’t perform that action at this time.