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 / twenty23-theme.json
Created November 18, 2022 19:50
twenty23 teme file as example of supported parameters
{
"$schema": "https://schemas.wp.org/trunk/theme.json",
"version": 2,
"customTemplates": [
{
"name": "blank",
"postTypes": [
"page",
"post"
],
@doiftrue
doiftrue / kama_previous_posts_from_cat.php
Last active January 10, 2024 03:24
[wp-kama embed] Previous Entries from Category >>> https://wp-kama.com/2102
<?php
/**
* Previous posts from the category (relative to the current post) + circular linking
* Parameters passed to the function. Default values are indicated in parentheses.
*
* @param int $post_num (5) Number of links.
* @param string $format ('') Output format: `{thumb} {date:j.M.Y} - {a}{title}{/a} ({comments})`.
* @param string $cache ('') Enable cache (default is off). Write 1 to enable.
* @param string $list_tag (li) List tag.
* @param string $post_type (post) Type of post we are working with.
@doiftrue
doiftrue / kama_pagenavi.php
Last active January 10, 2024 03:24
[wp-kama embed] kama_pagenavi >>> https://wp-kama.ru/8/
/**
* A wp_pagenavi alternative. Creates pagination links on archive pages.
*
* @param array $args Function arguments.
* @param WP_Query $wp_query WP_Query object on which pagination is based. Defaults to global variable $wp_query.
*
* @return string Pagination HTML code.
*
* @link https://wp-kama.ru/8
* @author Timur Kamaev
@doiftrue
doiftrue / Same_Prefix_Post_Taxes_Rewrite.php
Last active January 10, 2024 03:25
[wp-kama embed] WordPress: Friendly URLs for a Dual Multi-level Taxonomy >>> https://wp-kama.com/1326
<?php
new Same_Prefix_Post_Taxes_Rewrite();
/**
* How it works.
*
* We have:
* - ``company`` — Flat post type.
* - ``catalog`` — Hierarchical taxonomy.
@doiftrue
doiftrue / Kama_Hard_Disable_Plugins_On_Front.php
Last active January 10, 2024 03:32
[wp-kama embed] How Disable Plugins on Front-end? >>> https://wp-kama.com/1704
<?php
/**
* Disables the connection of the specified plugins at the front and ajax requests.
*
* @version 2.0
* @author Kama (wp-kama.ru)
*/
class Kama_Hard_Disable_Plugins_On_Front {
@doiftrue
doiftrue / WP_CLI_Permalink_Manager_Deletion_Check.php
Last active January 10, 2024 08:05
[EPAM] WP CLI Commands for analyze (investigate) whether we can delete Permalink Manager plugin
@doiftrue
doiftrue / functions.php
Last active January 10, 2024 08:25
https://wp-kama.ru/16747. Дополнение к плагину KCC: в шаблоне выводиться ссылка из метаполя 'comp_ref', количество кликов по ней дублируются в метаполе записи 'comp_ref_clicks'.
<?php
## Добавлет/обновляет количество кликов по ссылке из метаполя 'comp_ref' в метаполе 'comp_ref_clicks'
//do_action('kcc_count_after', $args, $updated, $data );
add_action( 'kcc_count_after', 'write_postmeta_link_clicks' );
function write_postmeta_link_clicks( $args ){
$post_id = (int) $args['in_post'];
if(
// пост не указан - не наш случай
@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!
@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 / _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 ){