Skip to content

Instantly share code, notes, and snippets.

View andxbes's full-sized avatar

Bescenniy Andrey andxbes

View GitHub Profile
@andxbes
andxbes / disable_load_mo_files.php
Last active September 1, 2023 13:32
Отключение переводов на рест запросах в wordpress
<?php
add_filter('override_load_textdomain', function ($result, $domain, $mofile ) {
$url = urldecode($_SERVER["REQUEST_URI"]);
if (
(function_exists('is_ajax') && is_ajax())
|| str_contains($url, 'wp-json/')
|| str_contains($url, 'ap-api/')
) {
$result = true;
//error_log('отключаем переводы' .' ' . $domain );
@andxbes
andxbes / functions.php
Created February 10, 2022 08:04
WP 5.9 add support Align Full
<?php
add_theme_support( 'align-wide' );
<?php
//...
if( mb_strlen( $text ) > $rg['maxchar'] ){
$text = mb_substr( $text, 0, $rg['maxchar'] );
//$text = preg_replace( '/(.*)\s[^\s]*$/s', '\\1...', $text );
// прибиваем последнее слово
$text = preg_replace( "%(.*)\s[^\s]*$%s", '\\1'.$rg['more_text'], $text ); // del last word, it not complate in 99%
// если концом строки является обрубанный тег, рубаем его тоже.
$text = preg_replace("%(.*)[<][^>]*{$rg['more_text']}$%s", '\\1'. $rg['more_text'], $text );
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package GBet365;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
@andxbes
andxbes / gtag-test.html
Created January 5, 2021 13:03
dont working list_name in gtag
<!DOCTYPE html>
<html data-lt-installed="true" lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>Success – ArgoPrep</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-186074229-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
@andxbes
andxbes / debug.php
Created December 17, 2020 09:04
Вывести стек вызовов текущей функции
<?php
error_log(print_r(debug_backtrace(), true));
@andxbes
andxbes / amp_calculate_limit_custom_styles.js
Last active March 22, 2021 13:33
Amp подсчет свободного места под стили
// ==UserScript==
// @name Get bytes of custom style
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author andxbes
// @match https://argoprep.local/*
// @match https://argoprep.com/*
// @match https://*.argoprep.com/*
// @exclude https://argoprep.local/wp-*
@andxbes
andxbes / functions.php
Created October 8, 2020 06:18
Gutenberg редактор на всю ширину экрана
<?php
add_theme_support('editor-styles');
add_editor_style('style-editor.css');
@andxbes
andxbes / functions.php
Created October 1, 2020 12:26
Вывод гутенберг блоков в разделах
<?php
add_filter('term_description', 'shortcode_unautop');
add_filter('term_description', 'do_shortcode');
//удаляем автопростановку тегов вордпрессом
remove_filter('the_content', 'wpautop');
//Выводим через шорткод гутенберг блоки
add_shortcode("get_wp_block", function($atts, $content = null) {
extract(shortcode_atts(array(
'id' => '',
@andxbes
andxbes / functions.php
Last active December 3, 2020 12:49
Свое количестов записей для архивов и сортировка по произвольному полю для конкретного раздела
<?php
//свое количество записей в каждом разделе
function custom_posts_per_page($query) {
if (!is_admin() && $query->is_main_query()) {//чтобы не трогать админку , и генерацию меню .
if (is_archive()) {
$query->set('posts_per_page', 20);
}//endif
if (is_category(4)) {
// $query->set('order', 'ASC');