Skip to content

Instantly share code, notes, and snippets.

View doiftrue's full-sized avatar
💻
codding...

Timur Kamaev doiftrue

💻
codding...
View GitHub Profile
@doiftrue
doiftrue / disable-aggressive-updates.php
Created January 16, 2024 20:18
[wpkama embed] https://wp-kama.com/2345 Disable Aggressive Updates.
<?php
/**
* Disable forced checking for new WP, plugins, and theme versions in the admin panel,
* so that it doesn't slow down when you haven't visited for a long time and then visit...
* All checks will happen unnoticed through cron or when you visit the "Dashboard > Updates" page.
*
* @see https://wp-kama.ru/filecode/wp-includes/update.php
* @author Kama (https://wp-kama.ru)
* @version 1.1
@doiftrue
doiftrue / Kama_Breadcrumbs.php
Created January 11, 2024 01:25
[wpkama embed] https://wp-kama.ru/541 Breadcrumbs for WordPress
<?php
/**
* Breadcrumbs for WordPress
*
* @param string $sep Separator. Default is ' » '.
* @param array $l10n For localization. See the variable `$default_l10n`.
* @param array $args Options. See the variable `$def_args`.
*
* @return void Outputs HTML code to the screen
@doiftrue
doiftrue / kama_previous_posts_from_tax_lis.php
Last active March 16, 2024 16:04
[wp-kama embed] Interlinking posts in WordPress (previous posts from category). Function 2 -- https://wp-kama.com/2186
/**
* Предыдущие записи из рубрики (относительно текущей записи) +
* кольцевая перелинковка (можно указывать таксономию и тип записи).
*
* Кэширует результат в объектный кэш, если он включен.
*
* Вызываем функцию так:
*
* echo kama_previous_posts_from_tax_lis( [
* 'post_num' => 5,
@doiftrue
doiftrue / My_Best_Metaboxes.php
Created March 6, 2024 02:55
[wp-kama embed] https://wp-kama.ru/id_740 Example of custom post metabox
<?php
$my_metabox = new My_Best_Metaboxes( 'post' );
$my_metabox->init();
class My_Best_Metaboxes {
public $post_type;
static $meta_prefix = 'company_address';
@doiftrue
doiftrue / wp_nav_menu-object-cache.php
Created February 28, 2024 19:16
[wpkama embed] https://wp-kama.ru/16856 wp_nav_menu object cache
<?php
Pj_Cached_Nav_Menus::load();
/**
* Caches calls to wp_nav_menu().
*/
class Pj_Cached_Nav_Menus {
public static $ttl = 3600; // use 0 to cache forever (until nav menu update)
public static $cache_menus = array();
@doiftrue
doiftrue / Kama_Minmax_Post_Meta_Values.php
Created January 15, 2024 22:45
[wpkama embed] https://wp-kama.ru/9128 Gathers and caches the minimum and maximum value of the specified meta-field for the specified terms of the taxonomy
<?php
/**
* Gathers and caches the minimum and maximum value of the specified meta-field for the specified terms of the taxonomy.
* Suitable for obtaining the minimum and maximum prices of products from categories.
*
* The code caches the minimum and maximum numerical values in the post meta-fields for each category.
* It also collects the overall minimum and maximum values for the entire taxonomy.
*
* @changelog
@doiftrue
doiftrue / Kama_Post_List_Table_Thumb.php
Created January 15, 2024 21:05
[wpkama embed] https://wp-kama.ru/9227 Ability to upload and modify post thumbnails from the posts list table in the admin panel.
<?php
if( ! is_admin() ){
return;
}
add_action( 'admin_init', [ Kama_Post_List_Table_Thumb::class, 'init' ] );
/**
* Ability to upload and modify post thumbnails from the posts list table in the admin panel.
@doiftrue
doiftrue / _tab-on-presstab.js
Created January 14, 2024 06:12
[wpkama embed] https://wp-kama.com/2310 Tab Symbol (\t) in Textarea When Pressing TAB Key
/**
* \t (tab ⇆ tabulation) symbol in textarea when pressing tab on the keyboard.
*
* Adds initial indentation for selected text when pressing the `Tab` key.
* Or removes the initial indentation (4 spaces or TAB) when pressing `Shift + Tab`.
*
* @Author Kama (wp-kama.ru)
* @version 4.3
*/
document.addEventListener( 'keydown', function( event ){
@doiftrue
doiftrue / Kama_Disable_Gutenberg.php
Created January 14, 2024 04:07
[wpkama embed] https://wp-kama.ru/11130 Kama_Disable_Gutenberg
<?php
/***
* Disables Gutenberg (the new block editor in WordPress).
*
* @version 2.0
*/
did_action( 'plugins_loaded' )
? Kama_Disable_Gutenberg::init()
: add_action( 'plugins_loaded', [ Kama_Disable_Gutenberg::class, 'init' ] );
@doiftrue
doiftrue / define_wp_debug.php
Last active January 10, 2024 08:28
[wp-kama embed] https://wp-kama.ru/7791 Dynamically enable/disable the display of PHP errors in WordPress.
<?php
/**
* Dynamically enable/disable the display of PHP errors in WordPress.
*
* Installation:
* replace line 'define( WP_DEBUG, false );' in 'wp-config.php' file with this code.
*
* Enabling debug mode:
* NOTE: Strongly recommended to changing the 'debug' word to something more unique!