Skip to content

Instantly share code, notes, and snippets.

View mihdan's full-sized avatar
:octocat:
Code is poetry

Mikhail Kobzarev mihdan

:octocat:
Code is poetry
View GitHub Profile
@mihdan
mihdan / pluralize-ru.js
Created January 18, 2023 13:25 — forked from znechai/pluralize-ru.js
JavaScript - Plural forms for russian words
/**
* Plural forms for russian words
* @param {Integer} count quantity for word
* @param {Array} words Array of words. Example: ['депутат', 'депутата', 'депутатов'], ['коментарий', 'коментария', 'комментариев']
* @return {String} Count + plural form for word
*/
function pluralize(count, words) {
var cases = [2, 0, 1, 1, 1, 2];
return count + ' ' + words[ (count % 100 > 4 && count % 100 < 20) ? 2 : cases[ Math.min(count % 10, 5)] ];
}
<?php
add_action(
'enqueue_block_editor_assets',
function() {
wp_register_script(
'mihdan-editor-js',
get_theme_file_uri( 'js/editor.js' ),
[ 'wp-blocks' ],
filemtime( get_theme_file_path( 'js/editor.js' ) ),
true
@mihdan
mihdan / README-WordPress-FULLTEXT-Search.md
Created March 24, 2022 16:55 — forked from jesgs/README-WordPress-FULLTEXT-Search.md
WordPress Full Text Search Examples

Adding MySQL FULLTEXT Support to WordPress

FULLTEXT support to WordPress is simple if you have access to phpMyAdmin. If not, it can still be done but is a little trickier if you’re not used to command-line. We’ll demonstrate how to modify your WordPress database using phpMyAdmin.

How To Modify Database

  1. Start out by having a set of keywords to test against. You’ll need ‘before’ and ‘after’ test results. Also, I can’t stress this enough but back up your database before proceeding!

  2. Next, log into your phpMyAdmin page and navigate to your {prefix}_posts table.

  3. Click on the “Structure” tab.

@mihdan
mihdan / grammarly.sh
Created December 22, 2021 15:24
Script install Grammarly for Linux via PlayOnlinux
#!/usr/bin/env playonlinux-bash
# Date : (2021-04-05 04-20)
# Last revision : (2021-04-05 06-09)
# Wine version used : 6.3 staging
# Distribution used to test : Ubuntu 20.04 LTS
# Author : tiagovla
# PlayOnLinux : 4.3.4
# Script licence : MIT
[ "$PLAYONLINUX" = "" ] && exit 0
@mihdan
mihdan / fish_install.md
Created December 1, 2021 15:33 — forked from gagarine/fish_install.md
Install fish shell on macOS Mojave with brew

Installing Fish shell on MacOS (Intel and M1)

Fish is a smart and user-friendly command line (like bash or zsh). This is how you can instal Fish on MacOS and make your defaul shell.

Note that you need the https://brew.sh/ package manager.

You can also download the fish app from their website. I do recomand using brew because update are easier.

Install Fish

<?php
function tlap_plugin_default_values(){
$defaults = array(
'tlap_add_analytics_option' => array(
'tlap_excludepage' => '',
'tlap_timer_delay' => '5000',
),
'tlap_add_analytics_option_counters' => array(
@mihdan
mihdan / DNS Prefetch domains
Last active August 20, 2021 18:16 — forked from lukecav/DNS Prefetch domains
WP Rocket - Advanced Options Prefetch DNS requests examples
//maps.googleapis.com
//maps.gstatic.com
//fonts.googleapis.com
//fonts.gstatic.com
//ajax.googleapis.com
//apis.google.com
//google-analytics.com
//www.google-analytics.com
//ssl.google-analytics.com
//youtube.com
<?php
function return_canon () {
$canon_page = get_pagenum_link( 1 );
return $canon_page;
}
function canon_paged() {
if ( is_paged() ) {
add_filter( 'wpseo_canonical', 'return_canon' );
}
<?php
add_filter(
'widget_posts_args',
function ( $args, $instance ) {
if ( isset( $instance['cpt'] ) ) {
$args['post_type'] = $instance['cpt'];
}
if ( isset( $instance['order_by'] ) ) {