Skip to content

Instantly share code, notes, and snippets.

View mksddn's full-sized avatar
🎯
Focusing

Max Dudin mksddn

🎯
Focusing
View GitHub Profile
<?php
// Увеличение лимитов
function increase_limits() {
// Увеличение размера загружаемых файлов
@ini_set('upload_max_size', '128M');
@ini_set('post_max_size', '128M');
@ini_set('max_execution_time', '300');
@ini_set('memory_limit', '256M');
@mksddn
mksddn / wp_lazyload_img.php
Last active January 11, 2024 13:36
WP Lazy load for images
/**
* Добавление loading="lazy" к изображениям, добавленным через редактор
*/
add_filter ('the_content', 'add_lazy_load_tag');
function add_lazy_load_tag($content) {
return preg_replace('/img/', 'img loading="lazy"', $content);
}
@mksddn
mksddn / README.md
Created December 30, 2023 06:57 — forked from marcpinet/README.md
Activate Sublime Text 4 Build 4143 and below for ever (also maybe above, but not yet tried)

Activate Sublime Text (for ever)

  1. Go to https://hexed.it/
  2. Click Open File in the top left corner and select sublime_text.exe
  3. Press CTRL + F or on the Search for bar in the left panel and look for: 80 78 05 00 0f 94 C1
  4. Now in the editor, click on the first byte (80) and start replacing each byte by: C6 40 05 01 48 85 C9
  5. Finally, in the top left corner again, click on Save as and replace the old executable file with the newly created one.

Enjoy an Unlimited User License!

@mksddn
mksddn / wp_thumbnails_in_admin_column.php
Created December 6, 2023 06:49
Featured Images in an Admin Column and in Quick Edit
<?php
// just in a case, let’s activate feature images for your theme by adding the code below
add_action( 'after_setup_theme', function() {
add_theme_support( 'post-thumbnails' );
} );
// 1. Featured Images Column
@mksddn
mksddn / css_centering.css
Last active December 6, 2023 06:40
Centering css
.center {
position: absolute;
top: 50%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%)
}
@mksddn
mksddn / wp_robots.txt
Created November 19, 2023 15:17
robots.txt for WordPress
User-agent: * # Создаем секцию правил для роботов. * значит для всех
# роботов. Чтобы указать секцию правил для отдельного
# робота, вместо * укажите его имя: GoogleBot, Yandex.
Disallow: /cgi-bin # Стандартная папка на хостинге.
Disallow: /wp-admin/ # Закрываем админку.
Allow: /wp-admin/admin-ajax.php # Откроем аякс.
Disallow: /? # Все параметры запроса на главной.
Disallow: *?s= # Поиск.
Disallow: *&s= # Поиск.
Disallow: /search # Поиск.
@mksddn
mksddn / change_wp_url_sql.txt
Last active November 19, 2023 15:01
SQL change/update/replace WP site url
UPDATE wp_options SET option_value = REPLACE(option_value, 'http://old-site.ru', 'https://new-site') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://old-site.ru', 'https://new-site');
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://old-site.ru','https://new-site');
@mksddn
mksddn / soap_example.html
Created November 12, 2023 14:38
Simplest SOAP example
<html>
<head>
<title>SOAP JavaScript Client Test</title>
<script type="text/javascript">
function soap() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('POST', 'https://somesoapurl.com/', true);
// build SOAP request
@mksddn
mksddn / wc_discount_for_cart.php
Last active November 11, 2023 20:47
WooCommerce - Depending discount for entire cart
<?php
// Фиксированная скидка в процентах на всю корзину
function woo_discount_total(WC_Cart $cart)
{
if (is_admin() && !defined('DOING_AJAX')) {
return;
}
$discount = $cart->subtotal * 0.05; // 0.05 - это 5%
$cart->add_fee('Фиксированная скидка в 5% ', -$discount);
@mksddn
mksddn / wp_disable_gutenberg_by_template.php
Last active November 11, 2023 21:00
WP - Disable Gutenberg by Template
<?php
/**
* Disable Editor
*
* @package ClientName
* @author Bill Erickson
* @since 1.0.0
* @license GPL-2.0+
**/