Skip to content

Instantly share code, notes, and snippets.

Mikko Saari msaari

Block or report user

Report or block msaari

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
@msaari
msaari / polylang.php
Created Mar 17, 2020
Relevanssi updated Polylang function
View polylang.php
<?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 Feb 29, 2020
Mailia ylläpidolle, kun tulee uusi artikkeli "pending"-tilaan
View pending.php
<?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}"
@msaari
msaari / Solarized Dark Colourful.itermcolors
Created Nov 28, 2019
Solarized Dark Colourful color settings for iTerm2
View Solarized Dark Colourful.itermcolors
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.25332435965538025</real>
@msaari
msaari / wp_remote_get_with_cache.php
Last active Nov 27, 2019
wp_remote_get_with_cache – Fetches remote data with dual-layer caching
View wp_remote_get_with_cache.php
<?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.
*
@msaari
msaari / multi-version-tests.sh
Created Nov 17, 2019
Test runner for running PHPUnit tests with many WordPress versions
View multi-version-tests.sh
#!/bin/sh
# Test runner for running Phpunit tests against multiple WordPress versions.
# Will fetch and install different WordPress versions in this directory:
BASE_PATH=~/multiwptest
if [ ! -d $BASE_PATH ]
then
echo "ERROR: Test directory $BASE_PATH is missing."
@msaari
msaari / composer.json
Created Nov 17, 2019
Relevanssi package test composer.json
View composer.json
{
"repositories": [
{
"type": "package",
"package": {
"name": "relevanssi/relevanssi-premium",
"version": "2.4.4",
"type": "wordpress-plugin",
"dist": {
"type": "zip",
@msaari
msaari / test-indexing.php
Created Nov 17, 2019
Tests the relevanssi_no_image_attachments function and feature.
View test-indexing.php
<?php
/**
* Tests the relevanssi_no_image_attachments function and feature.
*/
public function test_no_image_attachments() {
$this->delete_all_posts();
$image_attachment = array(
'post_title' => 'cat gif',
'post_mime_type' => 'image/gif',
'post_type' => 'attachment',
@msaari
msaari / phpunit.xml
Created Nov 17, 2019
PHPUnit configuration from Relevanssi
View phpunit.xml
<phpunit
bootstrap="tests/bootstrap.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
>
<php>
<ini name="display_errors" value="true"/>
@msaari
msaari / gist:69ea41f2d9f57fe27a841edd4b2a62b2
Last active Nov 17, 2019
Anna-Kaari Hakkarainen: Dioraama, s. 304–307
View gist:69ea41f2d9f57fe27a841edd4b2a62b2
Rakas Karl, olen pahoillani, etten koskaan vastannut sinulle. Haluan että tiedät tämän:
se johtui pelosta, elämisen pelosta. Ajattein, että en pystyisi elämään odotusten mukaisesti.
Ajattelin, että ihminen tarvitsee tabun. En usko siihen enää. Nyt tiedän, että ihminen
tarvitsee ihmettä, arjen yläpuolelle nousevaa. Rakkautta. Yhteyttä. Suggestiota. Kaikkea sitä
mitä me olimme.
Rakastin ja rakastan sinua enemmän kuin mitään koskaan. Anna anteeksi.
Mutta ajattele, jos onnistun, saamme elää ikuisesti yhdessä. Ikuisesti! Unohtaminen on
kuolemista. Sinä et unohda ikinä. Et unohda meitä.
@msaari
msaari / rlv_category_pinning.php
Created Nov 2, 2019
Relevanssi product category pinning
View rlv_category_pinning.php
<?php
/**
* This will lift all the product categories in the results on top of the results.
*/
add_filter( 'relevanssi_hits_filter', 'rlv_lift_category', 20 );
function rlv_lift_category( $hits ) {
$categories = array();
$other_posts = array();
foreach ( $hits[0] as $hit ) {
You can’t perform that action at this time.