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 | |
/** | |
* Attachment processing intermediary to work between Relevanssi and a Tika server. | |
* | |
* Installation instructions: | |
* 1. Save this as index.php. | |
* 2. Change the Tika server URL in the constructor to point to your own Tika server. | |
* 3. Upload this file in a directory on your server. | |
* | |
* @author Mikko Saari (mikko@mikkosaari.fi) |
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_only_pdfs', 10, 2); | |
function rlv_only_pdfs($block, $post_id) { | |
$mime = get_post_mime_type($post_id); | |
if (!empty($mime)) { | |
$block = true; | |
if (substr($mime, -3, 3) == "pdf") $block = false; |
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 or in a code snippet. Then rebuild the index. | |
add_filter( 'relevanssi_content_to_index', 'rlv_add_image_titles', 10, 2 ); | |
function rlv_add_image_titles( $content, $post ) { | |
global $wpdb; | |
$results = $wpdb->get_col( | |
$wpdb->prepare( | |
"SELECT post_title FROM $wpdb->posts WHERE post_parent = %d", |
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 or in a code snippet: | |
add_filter( 'relevanssi_modify_wp_query', 'rlv_woocommerce_filters' ); | |
function rlv_woocommerce_filters( $query ) { | |
// phpcs:disable WordPress.Security.NonceVerification.Recommended | |
$min_price = isset( $_REQUEST['min_price'] ) ? intval( $_REQUEST['min_price'] ) : false; | |
$max_price = isset( $_REQUEST['max_price'] ) ? intval( $_REQUEST['max_price'] ) : false; |
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_action( 'pre_get_posts', 'rlv_jetsmartfilters', 9999 ); | |
/** | |
* Makes JetSmartFilters use posts from Relevanssi. | |
* | |
* @param WP_Query $wp_query The wp_query object. | |
*/ | |
function rlv_jetsmartfilters( $wp_query ) { |
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_post_content', 'rlv_heading_boost' ); | |
function rlv_heading_boost( $content ) { | |
if ( preg_match_all( '/<h1.*?>(.*?)<\/h1>/', $content, $h1_headings ) ) { | |
foreach ( $h1_headings[1] as $heading ) { | |
$content .= " $heading $heading $heading $heading $heading $heading $heading $heading"; | |
} | |
} | |
if ( preg_match_all( '/<h2.*?>(.*?)<\/h2>/', $content, $h2_headings ) ) { |
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 | |
/** | |
* Fetches remote data with dual-layer caching. | |
* | |
* Uses wp_remote_get to fetch remote data. The data is cached twice: it's | |
* stored in a transient and an option. The transient is used as the main cache | |
* but if the transient has expired and the remote site doesn't respond, | |
* backup data from the option is returned. | |
* |
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_oxygen_section_content', function( $content ) { | |
if ( preg_match_all( '/\[ct_code_block.*?ct_code_block\]/', $content, $matches ) ) { | |
foreach ( $matches[0] as $match ) { | |
if ( preg_match_all( '/"code-php":"(.*?)"/', $match, $block_matches ) ) { | |
foreach ( $block_matches[1] as $encoded_text ) { | |
$content .= base64_decode( $encoded_text ); | |
} | |
} |
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
ALTER TABLE xx_posts ADD COLUMN `relevanssi_light_data` LONGTEXT | |
ALTER TABLE xx_posts ADD FULLTEXT `relevanssi_light_fulltext` (`post_title`,`post_content`,`post_excerpt`,`relevanssi_light_data`) |
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 | |
// Put this in your theme functions.php | |
add_filter( 'relevanssi_do_not_index', 'rlv_skip_page', 10, 2 ); | |
function rlv_skip_page( $skip, $page ) { | |
$excluded_pages = array( 123, 234 ); // List all the ID numbers of the excluded pages here. | |
if ( in_array( $page, $excluded_pages, true ) ) { | |
$skip = true; | |
} | |
return $skip; |
NewerOlder