This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('relevanssi_post_ok', 'zc_user_can_access_page', 10, 2); | |
// Return a Boolead of if a logged in user can access a page | |
function zc_user_can_access_page($post_ok, $page_id) | |
{ | |
// If Zippy Courses isn't on this site, skip this check | |
if (!class_exists('Zippy')) { | |
return $post_ok; | |
} | |
$zippy = Zippy::instance(); | |
// Get the student access middleware |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function rlv_is_a_pn($candidate) { | |
$array = str_split($candidate); | |
$has_letters = false; | |
$has_numbers = false; | |
foreach ($array as $letter) { | |
if (is_numeric($letter)) { | |
$has_numbers = true; | |
} | |
else { | |
$has_letters = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Add this function to theme functions.php */ | |
add_filter( 'pre_get_posts', 'rlv_block_search' ); | |
function rlv_block_search( $query ) { | |
if (!empty($query->query_vars['s'])) { | |
$blacklist = array( '大奖', 'q82' ); // add blacklist entries here; no need for whole words, use the smallest part you can | |
foreach( $blacklist as $term ) { | |
if( mb_stripos( $query->query_vars['s'], $term ) !== false ) exit(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!(is_admin() )) { | |
function defer_parsing_of_js ( $url ) { | |
if ( FALSE === strpos( $url, '.js' ) ) return $url; | |
if ( strpos( $url, 'jquery.js' ) ) return $url; | |
// return "$url' defer "; | |
return "$url' defer onload='"; | |
} | |
add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('relevanssi_hits_filter', 'rlv_find_exact_title_match'); | |
function rlv_find_exact_title_match($hits) { | |
$title_match = array(); | |
$the_rest = array(); | |
foreach ($hits[0] as $hit) { | |
if (mb_strtolower($hit->post_title) == $hits[1]) { | |
$title_match[] = $hit; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function relevanssi_the_permalink_media() { | |
global $post; | |
if ( $post->post_type != "attachment" ) { | |
the_permalink(); | |
} | |
else { | |
echo wp_get_attachment_url($post->ID); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add this code to theme functions.php | |
add_action( 'init', 'create_media_tax' ); | |
function create_media_tax() { | |
register_taxonomy( | |
'media_tag', | |
'attachment', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add this to theme functions.php | |
add_filter('relevanssi_do_not_index', 'rlv_no_image_attachments', 10, 2); | |
function rlv_no_image_attachments($block, $post_id) { | |
$mime = get_post_mime_type($post_id); | |
if (substr($mime, 0, 5) == "image") $block = true; | |
return $block; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Add this function to theme functions.php */ | |
add_filter('relevanssi_modify_wp_query', 'rlv_force_post_types'); | |
function rlv_force_post_types($query) { | |
$query->set('post_types', 'post,page,accommodation,room_type,things_to_do,tour'); | |
return $query; | |
} |
OlderNewer