Skip to content

Instantly share code, notes, and snippets.

View dexit's full-sized avatar
🎯
Focusing

Rihards Mantejs dexit

🎯
Focusing
View GitHub Profile
@dexit
dexit / breadcrumbs-list.php
Created July 2, 2025 13:29 — forked from louisesalas/breadcrumbs-list.php
Remove <span> in Yoast breadcrumbs before the <li> tags
<?php
/**
* Filter the output of Yoast breadcrumbs to remove <span> tags added by the plugin
* @param $output
*
* @return mixed
*/
function louise93_yoast_breadcrumb_output( $output ){
@dexit
dexit / yoast-acfpro.js
Created July 2, 2025 13:29 — forked from joeydenbraven/yoast-acfpro.js
Combines Yoast with ACF Pro - works with repeater and flexible fields
(function( $ ) {
var acfPlugin;
//http://stackoverflow.com/a/965962
jQuery.expr[':'].parents = function(a,i,m){
return jQuery(a).parents(m[3]).length < 1;
};
var AcfPlugin = function() {
@dexit
dexit / elementor-widgets-toggle-expand-first-item.js
Created July 2, 2025 13:26 — forked from mihdan/elementor-widgets-toggle-expand-first-item.js
Раскрывает первый элемент виджета Elementor -> Toggle по умолчанию
( function ( $ ) {
$( function () {
/**
* Раскрывает первый элемент виджета Toggle по умолчанию.
*/
$( '.elementor-toggle-item:first-child' )
.children( '.elementor-tab-title' )
.addClass( 'elementor-active' )
.attr({
'aria-expanded': 'true',
@dexit
dexit / example-skills-block
Created July 2, 2025 13:20 — forked from mihdan/example-skills-block
This example is just really simple, the main shortcode is simple enough to not need any options or globals applied, it simply wraps the innner shortcodes.
<?php
/**
* The Shortcode
*/
function ebor_skills_shortcode( $atts, $content = null ) {
$output = '<div class="skills-wrapper">'. do_shortcode($content) .'</div>';
return $output;
}
add_shortcode( 'machine_skills', 'ebor_skills_shortcode' );
@dexit
dexit / example-skills-block
Created July 2, 2025 13:20 — forked from mihdan/example-skills-block
This example is just really simple, the main shortcode is simple enough to not need any options or globals applied, it simply wraps the innner shortcodes.
<?php
/**
* The Shortcode
*/
function ebor_skills_shortcode( $atts, $content = null ) {
$output = '<div class="skills-wrapper">'. do_shortcode($content) .'</div>';
return $output;
}
add_shortcode( 'machine_skills', 'ebor_skills_shortcode' );
@dexit
dexit / wp-auto-post-thumbnail.php
Created July 2, 2025 13:19 — forked from mihdan/wp-auto-post-thumbnail.php
Автоматическая генерация обложки записи из первой прикрепленной к посту фотке.
<?php
/**
* Plugin Name: Auto Post Thumbnail
* Author: [email protected]
*/
add_action(
'save_post',
function ( $post_id, WP_Post $post ) {
if ( wp_is_post_revision( $post_id ) || wp_is_post_autosave( $post_id ) ) {
return;
<?php
add_filter(
'render_block',
function ( $block_content, $block ) {
if ( 'core/image' === $block['blockName'] ) {
$block_content = str_replace(
array( '<figure ', '</figure>' ),
array( '<p ', '</p>' ),
$block_content
);
@dexit
dexit / wp-auto-generate-alt-attribute.php
Created July 2, 2025 13:19 — forked from mihdan/wp-auto-generate-alt-attribute.php
Дописывание автоматически alt
<?php
/**
* Делаем alt для Превью поста. Функция автозаполнения alt должна быть отключена в плагинах типа
* Webcraftic Clearfy или любом другом, который устанавливает alt автоматически,
* так как там всегда генерирует на основе заголовка.
* В некоторых темах, например OceanWP alt прописан как заголовок статьи в самой теме,
* и там нужно дополнительно кодить. В Astra всё нормально работает
*
* @param array $attr Массив дефолтных атрибутов картинки.
*/
@dexit
dexit / wp-add-custom-mime-type.php
Created July 2, 2025 13:19 — forked from mihdan/wp-add-custom-mime-type.php
Add custom mime type for WordPress
<?php
function mihdan_edit_upload_types( $existing_mimes = array() ) {
// allow .woff
$existing_mimes['woff'] = 'font/woff';
// disallow .jpg files
unset( $existing_mimes['jpg'] );
return $existing_mimes;
}
@dexit
dexit / wordpress-last-modified.php
Created July 2, 2025 13:15 — forked from mihdan/wordpress-last-modified.php
Устанавливает заголовок `Last-Modified` для WordPress и умеет обрабатывать заголовок `HTTP_IF_MODIFIED_SINCE`
<?php
add_action( 'template_redirect', 'set_last_modified_headers', 999 );
function set_last_modified_headers() {
if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX )
|| ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST )
|| ( defined( 'REST_REQUEST' ) && REST_REQUEST )
|| ( is_admin() ) ) {
return;