Skip to content

Instantly share code, notes, and snippets.

View andxbes's full-sized avatar

Bescenniy Andrey andxbes

View GitHub Profile
@andxbes
andxbes / main.js
Created February 22, 2024 09:33
Ninja forms validate email
// On Document Ready...
jQuery(document).ready(function ($) {
if (typeof Marionette !== 'undefined') {
var myCustomFieldController = Marionette.Object.extend({
initialize: function () {
var submitChannel = Backbone.Radio.channel('submit');
this.listenTo(submitChannel, 'validate:field', this.validateRequired);
var fieldsChannel = Backbone.Radio.channel('fields');
@andxbes
andxbes / block-submit.js
Created November 23, 2023 09:52
CF-7 block submit button on sending
export default function cf_7() {
console.info('cf-7');
let cf_7 = document.querySelectorAll('.wpcf7-form');
if (cf_7 && cf_7.length > 0) {
cf_7.forEach(function (cf_7_form) {
const submit_button = cf_7_form.querySelector('.wpcf7-submit');
if (submit_button) {
cf_7_form.addEventListener('submit', function (event) {
submit_button.setAttribute('disabled', '');
@andxbes
andxbes / input_file.js
Created October 31, 2023 13:14
input_file.js
//Change label for file
jQuery(document).ready(function ($) {
let $file_container = $('.file-upload');
if ($file_container.length > 0) {
$file_container.each(function () {
let $container = $(this);
let $file_input = $container.find('.wpcf7-file');
let $label = $container.find('.file-label__text');
$file_input.change(function () {
@andxbes
andxbes / rewrite_blog.php
Last active August 27, 2023 08:08
rewrite_blog.php
<?php
add_action('init', function () {
add_rewrite_rule('insights/([^/]+)/([^/]+)/?$', 'index.php?category_name=$matches[1]&name=$matches[2]&post_type=post', 'top');
add_rewrite_rule('lp/([^/]+)/?$', 'index.php?name=$matches[1]&post_type=e-landing-page', 'top');
});
add_filter('pre_post_link', function ($permalink, $post, $leavename) {
if ($post->post_type === 'post') {
$permalink = '/insights' . $permalink;
<?php
add_action('woocommerce_add_to_cart_fragments', function($fragments){
$count = WC()->cart->get_cart_contents_count();
ob_start(); ?>
<span class="cart-value" <?php echo ($count == 0) ? 'style="display:none;"' : ''; ?>><?php echo $count ?></span>
<?php $fragments['span.cart-value'] = ob_get_clean();
return $fragments;
@andxbes
andxbes / google_map_links.php
Created July 6, 2023 16:24
Google map links
@andxbes
andxbes / rewrite_rules.php
Last active June 30, 2023 07:25
Кастомный url для таксономий
<?php
class Theme_Rewrite_Rules
{
public function __construct()
{
add_action('wp_loaded', [$this, '_maybe_rewrite_rules']);
add_action('init', [$this, '_change_term_struct']);
}
@andxbes
andxbes / index.css
Created May 15, 2023 08:47
True .alignfull
main .alignfull {
margin: 2rem calc(50% - (50vw - var(--scrollbar-width) / 2)) !important;
max-width: calc(100vw - var(--scrollbar-width)) !important;
width: calc(100vw - var(--scrollbar-width));
}
@andxbes
andxbes / firefox
Created July 28, 2022 07:56
Добавить в доверенные ключи и разрешить загрузку по самоподписанному сертификату
В firefox
about:config
ищем security.enterprise_roots.enabled , выставляем в true
для Chrome
нужно набрать на странице thisisunsafe
@andxbes
andxbes / change version php on Mac OS
Last active July 14, 2022 06:32
Смена, понижение, версии php на Mac OS
brew install php@8.0
brew unlink php@8.1
brew services stop php@8.1
brew link --force --overwrite php@8.0
brew services start php@8.0
brew services restart php
php -v
sudo nginx -s reload