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 / get_blogid_from_url.sh
Created February 15, 2024 22:26 — forked from dangtrinhnt/get_blogid_from_url.sh
Get blog_id from url using wp-cli
#! /bin/bash
# example csv file, mycsv.csv:
#
# path,some_field
# somepath,some_value
# anotherpath,another_value
# ...
#
# run the following command:
# ./get_blogid_from_url.sh mycsv.csv myblog.com /wordpress/path > result.csv
@mihdan
mihdan / composer_beget.txt
Created November 27, 2023 17:11 — forked from Dreamer0x01/composer_beget.txt
Команды composer на хостинге beget
На некторых хостингах, в том числе хостинге beget, требуется явно указывать версию php для композера, так как версия php в консоли часто отличается от версии, заданной в контрольной панели для сайта.
(Текущую версию php для консоли можно узнать командой php -v)
Например, для версии 7.4 команда будет такая:
composer-php7.4 install
Для других версий php алиасы соответствующих версий будут такими:
composer-php5.3
composer-php5.4
composer-php5.5
composer-php5.6
@mihdan
mihdan / wp-config.php
Created August 9, 2023 21:06 — forked from MikeNGarrett/wp-config.php
All those damned wp-config constants you can never remember.
<?php
// PHP memory limit for this site
define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' ); // Increase admin-side memory limit.
// Database
define( 'WP_ALLOW_REPAIR', true ); // Allow WordPress to automatically repair your database.
define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', true ); // Don't make database upgrades on global tables (like users)
// Explicitely setting url
@mihdan
mihdan / hooks.php
Created April 13, 2023 20:25 — forked from lilumi/hooks.php
Disable WPML String Translations for Gutenberg Blocks
<?php
/*
WPML checks for gutenberg like this:
\WPML_Page_Builders_Defined->has()
```
if ( 'gutenberg' === $page_builder ) {
if ( version_compare( $wp_version, '5.0-beta1', '>=' ) ) {
return true;
}
}
@mihdan
mihdan / tsf-custom-image-generator.php
Created March 23, 2023 07:05 — forked from sybrew/tsf-custom-image-generator.php
Example snippet to prepend and append image generators for The SEO Framework.
<?php
// Do not include this PHP opening tag if PHP is already opened...
// Ref: https://theseoframework.com/docs/using-filters/
add_filter( 'the_seo_framework_image_generation_params', 'my_tsf_custom_image_generation_args', 10, 3 );
/**
* Adjusts image generation parameters.
*
* @link https://theseoframework.com/docs/api/filters/#append-image-generators-for-social-images
@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)] ];
}
@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 / 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