Skip to content

Instantly share code, notes, and snippets.

@Anduin-
Anduin- / elastic-hooks.php
Created December 5, 2018 07:03
elastic
<?php
/**
* Created by PhpStorm.
* User: tim
* Date: 2/5/18
* Time: 10:56 PM
*/
add_filter('ep_post_sync_args', 'add_content_to_elastic', 10, 2);
function add_content_to_elastic($post_args, $post_id)
<?php
function get_word_form( $count, $word_forms = [ 'предмет', 'предмета', 'предметов' ] ) {
$count = preg_replace( '/[^\d]/', '', $count );
$n100 = $count % 100;
$n10 = $count % 10;
if ( ( $n100 > 10 ) && ( $n100 < 20 ) ) {
return $word_forms[2];
} elseif ( $n10 == 1 ) {