Skip to content

Instantly share code, notes, and snippets.

View msaari's full-sized avatar

Mikko Saari msaari

View GitHub Profile
@msaari
msaari / indexing.php
Created August 28, 2020 03:51
Relevanssi indexing.php without doc count update
<?php
/**
* /lib/indexing.php
*
* @package Relevanssi
* @author Mikko Saari
* @license https://wordpress.org/about/gpl/ GNU General Public License
* @see https://www.relevanssi.com/
*/
@msaari
msaari / rlv_category_dropdown.php
Last active July 20, 2020 02:53
Improved rlv_category_dropdown
<?php
function rlv_category_dropdown() {
global $rlv_categories_present, $wp_query;
$select = "<div id='catCheckboxes'><p>Choose a category:</p>";
$cat_params = array_map( 'intval', explode( ',', $wp_query->query_vars['cats'] ) );
foreach ( $rlv_categories_present as $cat_id => $cat_name ) {
$checked = '';
if ( in_array( $cat_id, $cat_params, true ) ) {
@msaari
msaari / relevanssi_index_tablepress_acf.php
Last active June 27, 2020 01:48
Index TablePress shortcodes in ACF fields
<?php
add_filter( 'relevanssi_custom_field_value', 'rlv_tablepress_in_acf' );
function rlv_tablepress_in_acf( $value ) {
$tablepress_controller = relevanssi_enable_tablepress_shortcodes();
$post_before_shortcode = $post;
$value[0] = do_shortcode( $value[0] );
$post = $post_before_shortcode;
<?php
add_action('template_redirect', 'one_match_redirect');
function one_match_redirect() {
if (is_search()) {
global $wp_query;
if ($wp_query->post_count == 1) {
wp_redirect( get_permalink( $wp_query->posts['0']->ID ) );
exit();
}
@msaari
msaari / relevanssi-arabic.php
Created May 3, 2020 15:20
Relevanssi Arabic support
<?php
add_filter( 'relevanssi_remove_punctuation', 'rlv_arabic_remap', 9 );
function rlv_arabic_remap( $a ) {
$remap = array(
'إ' => 'ا',
'آ' => 'ا',
'أ' => 'ا',
'ئ' => 'ى',
'ة' => 'ه',
@msaari
msaari / searchform.php
Created April 23, 2020 16:43
Searchform.php
<div role="search" class="search-form-wrapper">
<form method="get" class="g1-searchform-tpl-default search-form" action="https://beezfac.com/m/">
<label>
<span class="screen-reader-text">Search for:</span>
<input type="search" class="search-field" placeholder="Search …" value="" name="s" title="Search for:">
<input type="hidden" name="searchblogs" value="all" />
</label>
<button class="search-submit">Search</button>
</form>
</div>
@msaari
msaari / search.php
Created April 9, 2020 12:32
Dokan search template
<?php
/**
* The template for displaying Search Results pages.
*
* @package dokan
* @package dokan - 2014 1.0
*/
get_header();
?>
@msaari
msaari / wp-widget-rss-alpha.php
Created April 1, 2020 09:51
WP RSS Widget Alpha
<?php
/**
* Plugin Name: WP Widget RSS Alpha
* Description: WP RSS Widget, joka näyttää koko syötteen aakkosjärjestyksessä
* Version: 1
* Author: Mikko Saari
* Author URI: http://www.mikkosaari.fi/
*/
/**
@msaari
msaari / polylang.php
Created March 17, 2020 12:45
Relevanssi updated Polylang function
<?php
function relevanssi_polylang_where_include_terms( $where ) {
global $wpdb;
$current_language = substr( get_locale(), 0, 2 );
if ( function_exists( 'pll_current_language' ) ) {
$current_language = pll_current_language();
}
$languages = get_terms( array( 'taxonomy' => 'language' ) );
@msaari
msaari / pending.php
Created February 29, 2020 08:29
Mailia ylläpidolle, kun tulee uusi artikkeli "pending"-tilaan
<?php
add_action( 'transition_post_status', 'mailia_pendingistä', 10, 3 );
function mailia_pendingistä( $vanha_status, $uusi_status, $post_id ) {
if ( 'pending' === $uusi_status ) {
$post = get_post( $post_id );
wp_mail(
get_bloginfo( 'admin_email' ),
'Uusi hyväksymistä odottava artikkeli',
"{$post->post_title}\n\n{$post->post_content}"