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
@jchristopher
jchristopher / functions.php
Last active Jun 19, 2019
Tell SearchWP to incercept ACF Relationship Field searches
View functions.php
<?php
// Callback to have SearchWP intercept ACF Relationship field searches.
function my_searchwp_acf_relationship_field_search( $args, $field, $post_id ) {
if ( empty( $args['s'] ) || ! class_exists( 'SWP_Query' ) ) {
return $args;
}
// Assume that the SearchWP engine to use is the defined admin search engine
// from SearchWP's Advanced settings screen.
@jchristopher
jchristopher / gutenberg.html
Last active May 14, 2019
Sample of reusable block in Gutenberg
View gutenberg.html
<!-- wp:paragraph -->
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus
tincidunt nunc vel consequat dapibus. Pellentesque aliquet felis
nulla, sit amet efficitur mauris finibus in. </p>
<!-- /wp:paragraph -->
<!-- wp:block {"ref":50} /-->
<!-- wp:heading -->
<h2>Lipsum dolor sit</h2>
@jchristopher
jchristopher / gutenberg.html
Last active May 14, 2019
Sample of Gutenberg content in the database
View gutenberg.html
<!-- wp:paragraph -->
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus tincidunt nunc vel
consequat dapibus. Pellentesque aliquet felis nulla, sit amet efficitur mauris
finibus in. </p>
<!-- /wp:paragraph -->
<!-- wp:heading -->
<h2>Lipsum dolor sit</h2>
<!-- /wp:heading -->
View functions.php
<?php
add_filter( 'searchwp_do_settings_backup', '__return_false' );
@jchristopher
jchristopher / functions.php
Created Apr 26, 2019
Tell SearchWP to use <span> for highlights instead of <mark>
View functions.php
<?php
// Tell SearchWP to use <span> for highlights instead of <mark>.
add_filter( 'searchwp_th_use_span', '__return_true' );
@jchristopher
jchristopher / functions.php
Created Apr 26, 2019
Prevent SearchWP's highlighter from stripping Shortcodes prior to highlighting
View functions.php
<?php
// Prevent SearchWP's highlighter from stripping Shortcodes prior to highlighting.
add_filter( 'searchwp_th_strip_shortcodes', '__return_false' );
@jchristopher
jchristopher / functions.php
Created Apr 26, 2019
Pre-process Custom Field content before it is sent to SearchWP's highlighter
View functions.php
<?php
// Pre-process Custom Field content before it is sent to SearchWP's highlighter.
add_filter( 'searchwp_th_pre_process_meta_value', function( $meta_value, $meta_key, $post_id ) {
// TODO: Customize $meta_value in any way you see fit.
return $meta_value;
}, 20, 3 );
@jchristopher
jchristopher / functions.php
Created Apr 26, 2019
Pre-process content before it is sent to SearchWP's highlighter
View functions.php
<?php
// Pre-process content before it is sent to SearchWP's highlighter.
add_filter( 'searchwp_th_pre_process_content', function( $content ) {
// TODO: Customize $content in any way you see fit.
return $content;
} );
@jchristopher
jchristopher / functions.php
Created Apr 26, 2019
Customize the 'password protected' message returned by SearchWP's highlighter
View functions.php
<?php
// Customize the 'password protected' message returned by SearchWP's highlighter.
add_filter( 'searchwp_th_password_required_message', function( $message ) {
return __( 'There is no excerpt because this is a protected post.' );
} );
@jchristopher
jchristopher / functions.php
Created Apr 26, 2019
Tell SearchWP to use partial matches when highlighting
View functions.php
<?php
// Tell SearchWP to use partial matches when highlighting.
add_filter( 'searchwp_th_partial_matches', '__return_true' );
You can’t perform that action at this time.