Code Snippets
PHP
add_filter( 'asp_custom_fonts', 'bubdev_disable_google_fonts' );
/**
* Ajax Search Pro: Disable Google Fonts
*/
function bubdev_disable_google_fonts( $css_arr ) {
return array();
}
add_filter( 'asp_results', 'bubdev_search_asp_exclusions', 10, 1 );
/**
* Ajax Search Pro: Filter Search Results
*/
function bubdev_search_asp_exclusions( $results ) {
foreach ( $results as $k=>&$r ) {
// Hide post type from readers.
if ( $r->post_type == 'bub_devpost' && ! current_user_can( 'edit_page' ) ) {
unset($results[$k]);
}
}
return $results;
}
JS
/**
* Control Results Tabindex
*
* Improve keyboard navigation (tab key) through results box.
*
* - Tab directly to first search result, ignoring the custom scroolbar.
* - Ignore links inside result descriptions, while tabbing through results.
*/
$( document ).ready( function() {
aspControlResultsTabindex();
function aspControlResultsTabindex() {
'use strict';
$( document ).on( 'keydown', function( e ) {
if ( e.keyCode == 9 && ! e.altKey && ! e.ctrlKey
&& 'search'.indexOf( document.activeElement.type.toLowerCase()) !== -1 ) {
var $dragger = $( '.mCustomScrollBox' );
var $linksInResultDescriptions = $( '.asp_res_text' ).find( 'a' );
$dragger.add( $linksInResultDescriptions ).attr( 'tabindex', -1 );
}
});
}
});