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
server {
server_name wp.com;
root /var/www/wp; # путь к WP
index index.php;
gzip on; # включаем сжатие gzip
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
# Global restrictions configuration file.
@mihdan
mihdan / wc-auto-update-cart.php
Created April 10, 2020 17:40
Автоматическое обновление корзины WooCommerce при изменении количества товара в ней
<?php
/**
* Автообновление корзины WooCommerce
* при изменении количества товара.
*/
add_action(
'wp_footer',
function () {
if ( is_cart() ) {
?>
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
user = mysql
@mihdan
mihdan / Grandtheftauto5-linux.md
Created January 24, 2020 09:11 — forked from BeauBouchard/Grandtheftauto5-linux.md
How to install Grand Theft Auto V on Linux (Ubuntu x64 14.04) using wine.

How to install Grand Theft Auto V on Linux (Ubuntu x64 14.04) using wine.

Date Completed: Not done yet ~~ April 23rd 2015

My Test System

  • Video Card: Nvidia GTX 465 (lol right? Game runs shitty)
  • Driver: tested on 331.38, works on 331.38+
  • OS: Ubuntu x64 14.04
  • POL: I used Play on linux 4, I assume most of the capabilities are in winetricks
  • Wine: wine-staging Sun, 19 Apr 2015 version 1.7.41 x64 bit
@mihdan
mihdan / functions.php
Created January 17, 2020 07:35 — forked from kagg-design/functions.php
Fix performance problem with woodmart autoload.
<?php
if( ! function_exists( 'woodmart_autoload' ) ) {
function woodmart_autoload($className) {
global $woodmart_files;
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strripos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
@mihdan
mihdan / wp-attachment-url-to-post-id.php
Last active January 11, 2022 15:19
Возвращает ID медиафайла по переданному URL.
<?php
/**
* Возвращает ID медиафайла по переданному URL.
*
* @param string $url Ссылка на файл в любом формате, вплоть до image.jpg или просто name_image.
* @return int $attachment_id ID медифайла.
* @version 2.0
*/
function attachment_url_to_post_id( string $url ): int {
global $wpdb;
@mihdan
mihdan / gist:b787f705259365d30c8795f5fed4e44e
Created December 20, 2019 16:18 — forked from billerickson/gist:2047229
Improve performance of WP_Query
<?php
$args = array(
// Normal query goes here //
'no_found_rows' => true, // counts posts, remove if pagination required
'update_post_term_cache' => false, // grabs terms, remove if terms required (category, tag...)
'update_post_meta_cache' => false, // grabs post meta, remove if post meta required
);
@mihdan
mihdan / Postman.desktop
Created December 18, 2019 19:28 — forked from aviskase/Postman.desktop
Install Postman
[Desktop Entry]
Encoding=UTF-8
Name=Postman
Exec=postman
Icon=/home/USERNAME/Postman/app/resources/app/assets/icon.png
Terminal=false
Type=Application
Categories=Development;
@mihdan
mihdan / cf7-to-tlg.php
Last active October 23, 2023 20:47 — forked from zevilz/cf7-to-tlg.php
Send message from Contact Form 7 to Telegram
<?php
$z_cf7_to_tlg_args = [
'bot_token' => '618641506:AAGa_WvKonJOxXpdZCHb66Qsk7erwerwe',
'receivers' => [
-7878979791231323,
],
];
function z_cf7_to_tlg_send_message( $message, $receiver ) {
global $z_cf7_to_tlg_args;
$params['text'] = wp_strip_all_tags( $message );
@mihdan
mihdan / gist:b4a218961bc609b0246ad2aa9ba0c232
Last active December 17, 2019 10:30 — forked from nkarpeev/gist:5fb28d13e0aa02494d1464ecea374fd1
Using the_posts_pagination for custom page template WordPress
<?php
// Define page_id
$page_ID = get_the_ID();
// Define paginated posts
$page = get_query_var( 'page' );
// Define custom query parameters
$args = array(
'post_type' => array( 'post', 'book', 'movie' ), // post types