Skip to content

Instantly share code, notes, and snippets.

View artikus11's full-sized avatar
🥕
Create plugins

Artem Abramovich artikus11

🥕
Create plugins
View GitHub Profile
@artikus11
artikus11 / xml_sitemap_img
Created January 4, 2017 21:08
Exclude to xml sitemap image
add_filter( 'wpseo_xml_sitemap_img', '__return_false' );
@artikus11
artikus11 / menu_no_link
Last active November 13, 2022 18:55
Уборка циклических ссылок в меню
@artikus11
artikus11 / russify_months
Created January 6, 2017 14:31
Руссифицирует месяца и недели в дате
/**
* Руссифицирует месяца и недели в дате.
* Функция для фильтра date_i18n.
* @param строка $date Дата в принятом формате
* @param строка $req_format Формат передаваемой даты
* @return Дату в русском формате
*/
function russify_months( $date, $req_format ){
// в формате есть "строковые" неделя или месяц
if( ! preg_match('~[FMlSD]~', $req_format ) ) return $date;
@artikus11
artikus11 / Добавление колонок
Created January 7, 2017 08:29
Добавление колонок к кастомным постам (произвольные поля и миниатюра)
/* Подключаем и изменяем колонки в админке
/* ------------------------------------ */
function art_get_featured_image($post_ID) {
$post_thumbnail_id = get_post_thumbnail_id($post_ID);
if ($post_thumbnail_id) {
$post_thumbnail_img = wp_get_attachment_image_src($post_thumbnail_id, 'thumbnail');
return $post_thumbnail_img[0];
}
}
@artikus11
artikus11 / .htaccess
Last active January 14, 2022 08:51
Заготовка для подключения браузерного кеширования
Включение кеша браузера
=====
Вариант 1
===
<ifModule mod_headers.c>
<FilesMatch "\.(js|css|txt)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
<FilesMatch "\.(flv|swf|ico|gif|jpg|jpeg|png)$">
Header set Cache-Control "max-age=2592000"
jQuery(document).ready(function($) {
$(".post__body").magnificPopup({
delegate: "p a[href$='.jpg'],p a[href$='.jpeg'],p a[href$='.gif'],p a[href$='.png']",
type: 'image',
closeOnContentClick: true,
mainClass: 'mfp-img-mobile',
image: {
verticalFit: true
},
});
add_filter( 'woocommerce_register_post_type_product', 'artabr_modify_product_post_type' );
function artabr_modify_product_post_type( $args ) {
$args['labels']['name'] = 'Услуги';
$args['labels']['singular_name'] = 'Услуга';
$args['labels']['menu_name'] = 'Услуги';
return $args;
}
class WC_Ya_delivery_Picpoint extends WC_Shipping_Method {
public function __construct( $instance_id = 0 ) {
$this->id = 'ya_delivery_picpoint';
$this->method_title = 'Яндекс.Доставка - Самовывоз';
$this->instance_id = absint( $instance_id );
$this->supports = array(
'shipping-zones',
'instance-settings',
);
add_filter( 'woocommerce_states', 'artabr_woo_region_russia' );
function artabr_woo_region_russia( $states ) {
$states['RU'] = array(
"МОСКВА" => " Москва",
"САНКТ-ПЕТЕРБУРГ" => " Санкт-Петербург",
"АБАКАН" => " Абакан",
"АНАДЫРЬ" => " Анадырь",
"АНАПА" => " Анапа",
"АРХАНГЕЛЬСК" => " Архангельск",
"АСТРАХАНЬ" => " Астрахань",
// Add Featured meta to Publish box
add_action('post_submitbox_misc_actions', 'mts_featured_post_field');
function mts_featured_post_field () {
global $post;
/* check if this is a post, if not then we won't add the custom field */
/* change this post type to any type you want to add the custom field to */
if (get_post_type($post) != 'post')
return false;