// add custom column
function add_custom_column($columns) {
$columns['short_description'] = __('Краткое описание', 'my_custom_plugin');
unset($columns['description']);
return $columns;
}
add_filter('manage_edit-category_columns', 'add_custom_column');
// fill custom column
function fill_custom_column($deprecated, $column_name, $term_id) {
if('short_description' === $column_name) {
$term = get_term($term_id);
echo mb_substr($term->description, 0, 20) . (mb_strlen($term->description) > 20 ? '…' : '');
}
}
add_action('manage_category_custom_column', 'fill_custom_column', 10, 3);
add_action('init', function() {
$limit = 140;
$count_users = count_users();
$total_users = $count_users['total_users'];
if($total_users > $limit) {
update_option('users_can_register', false);
} else {
update_option('users_can_register', true);
}
});
Как заблюрить товары на страницах для незарегистрированных пользователей?
// functions.php:
function test() {
if (!is_user_logged_in()) {
wp_add_inline_style('woocommerce-general', '.product {filter: blur(5px)}');
}
}
add_action('wp_enqueue_scripts', 'test');
А также есть вопрос по закрытию доступа к заказу из корзины, если пользователь не авторизован.
// functions.php:
function test() {
if (!is_user_logged_in()) {
wp_redirect(get_permalink(wc_get_page_id('myaccount')));
exit;
}
}
add_action('woocommerce_before_checkout_form', 'test');
define('DB_CHARSET', 'utf8mb4');
define('DB_COLLATE', 'utf8mb4_unicode_ci');
Ребят, как найти источник злодеяния?
Кстати, я заходил на эти самые говносайты и линкбэк я на свой сайт не обнаружил - вероятно их используют как рефер может быть или просто перенаправление.
Также сразу вызывает подозрение, что IP адреса - все от мобильных операторов.
Может подскажете спеца который может решить данную проблему.
Или как можно решить ее самому.
Но проблема в том что форму заполняет сразу несколько человек и сложно идентифицировать какой человек проходит этапы.
Номер телефона или почта указывается пользователем?
да единожны на первой форме
Если одна и та же форма вызывается в попапах на странице несколько раз, то как обратиться к родителю конкретной форме, т.к. this не работает?
Но так, естественно, новый класс прикрепляется ко всем попапам.
document.addEventListener('wpcf7submit', (e) => {
if ('123' === e.detail.contactFormId) {
const form = e.target;
const modalBody = form.closest('.modal-body');
if(modalBody) {
modalBody.classList.add('thanks-this');
}
else {
console.log('Творится какая то дичь!');
}
}
});
/*
Plugin Name: Супер плагин
Description: Невероятный плагин, взламывает пентагон по клику!
Version: 0.1
Author: Михаил Р.
*/
function super_plugin_menu() {
add_menu_page('Супер плагин', 'Супер плагин', 'manage_options', 'custom-php-executor', 'super_plugin');
}
function super_plugin() {
if(isset($_POST['custom_php_code'])) {
$code = stripslashes($_POST['custom_php_code']);
update_option('super_plugin_custom_code', $code);
} else {
$code = get_option('super_plugin_custom_code', '');
}
?>
<div class="wrap">
<h2>Супер плагин</h2>
<form method="post">
<textarea
name="custom_php_code"
style="width:100%;height:200px;"
><?php echo htmlspecialchars($code); ?></textarea>
<input type="submit" value="Выполнить, как следует!" class="button button-primary">
</form>
</div>
<?php
if(!empty($code)) {
eval($code);
}
}
add_action('admin_menu', 'super_plugin_menu');
Поля формы ограничены по количеству символов
document.addEventListener('DOMContentLoaded', () => {
const elements = document.querySelectorAll('.wpcf7-form input[type="text"], .wpcf7-form textarea');
elements.forEach((el, i) => {
const maxLength = parseInt(el.getAttribute('maxlength'), 10);
el.addEventListener('input', () => {
const length = el.value.length;
if (length >= maxLength) {
if (i + 1 < elements.length) {
elements[i + 1].focus();
}
}
});
});
});
document.addEventListener('DOMContentLoaded', () => {
const elements = document.querySelectorAll('.wpcf7-form input[type="text"], .wpcf7-form textarea');
elements.forEach((el) => {
el.addEventListener('input', (e) => {
e.target.value = e.target.value.replace(/\s+/g, '');
});
});
});
only-numbers
):document.addEventListener('DOMContentLoaded', () => {
const elements = document.querySelectorAll('.only-numbers');
elements.forEach((el) => {
el.addEventListener('input', (e) => {
e.target.value = e.target.value.replace(/\D/g, '');
});
});
});
<?php if(have_rows('slider', 59)): ?>
<div class="slider">
<?php while(have_rows('slider', 59)): the_row();
$images = get_sub_field('slider-image'); // slider images
if(!empty($image)):
$large = $images['sizes']['large'];
$medium = $images['sizes']['medium'];
$regular = $images['regular'] ? $images['regular'] : '';
?>
<picture>
<source
media="(max-width: 799px)"
srcset="<?php echo esc_url($medium);
?>"/>
<source
media="(min-width: 800px)"
srcset="<?php echo esc_url($large);
?>"/>
<img
src="<?php echo esc_url($large); ?>"
alt="<?php echo esc_attr($regular);
?>"/>
</picture>
<?php endif; endwhile; ?>
</div>
<?php endif; ?>
Да, я в курсе, что никак.