Skip to content

Instantly share code, notes, and snippets.

View a-zhary's full-sized avatar
💻
Happy Coding

Anton Zhary a-zhary

💻
Happy Coding
View GitHub Profile
@a-zhary
a-zhary / wp-sync.sh
Created October 5, 2023 06:08 — forked from tacone/wp-sync.sh
Quick script to sync your dev box to a production Wordpress
#!/bin/bash
# Syncronize a local Wordpress installation with a remote one.
#
#
# Requires wp-cli.phar installed somewhere.
WP_CLI=/usr/local/bin/wp
# Remote settings
@a-zhary
a-zhary / gutenberg-helpers.js
Created June 2, 2023 18:18 — forked from KevinBatdorf/gutenberg-helpers.js
WordPress check Gutenberg editor is ready
import { select, subscribe } from '@wordpress/data'
export function whenEditorIsReady() {
return new Promise((resolve) => {
const unsubscribe = subscribe(() => {
// This will trigger after the initial render blocking, before the window load event
// This seems currently more reliable than using __unstableIsEditorReady
if (select('core/editor').isCleanNewPost() || select('core/block-editor').getBlockCount() > 0) {
unsubscribe()
resolve()
@a-zhary
a-zhary / .htaccess
Created July 20, 2022 11:19
Elementor resolve 500 error
php_value upload_max_filesize 512M
php_value post_max_size 512M
php_value max_execution_time 300
php_value max_input_time 300
php_value memory_limit 512M
@a-zhary
a-zhary / parse_utm.js
Created September 23, 2021 02:02 — forked from hunty/parse_utm.js
Парсит UTM метки и подставляет в скрытые поля
window.onload = function() {
// Parse the URL
function getParameterByName(name) {
var name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
var results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
// Give the URL parameters variable names
var source = getParameterByName('utm_source');
<?php
$args = array(
'label' => '', // Text in Label
'class' => '',
'style' => '',
'wrapper_class' => '',
'value' => '', // if empty, retrieved from post meta where id is the meta_key
'id' => '', // required
'name' => '', //name will set from id if empty
@a-zhary
a-zhary / bootstrap-4-sass-mixins-cheat-sheet.scss
Created June 29, 2020 22:28 — forked from anschaef/bootstrap-4-sass-mixins-cheat-sheet.scss
Bootstrap 4 Sass Mixins [Cheat sheet with examples]
/* -------------------------------------------------------------------------- */
// All Bootstrap 4 Sass Mixins [Cheat sheet]
// Updated to Bootstrap v4.5.x
// @author https://anschaef.de
// @see https://github.com/twbs/bootstrap/tree/master/scss/mixins
/* -------------------------------------------------------------------------- */
// Grid variables
$grid-columns: 12;
$grid-gutter-width: 30px;
@a-zhary
a-zhary / in_array_r
Created November 28, 2019 09:34
Search in multidimensional arrays
function atx_in_array_r($needle, $haystack, $strict = false)
{
foreach ($haystack as $item) {
if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && atx_in_array_r($needle, $item, $strict))) {
return true;
}
}
return false;
}
msgid ""
msgstr ""
"Project-Id-Version: my-plugin\n"
"Last-Translator: Anton Zhary a.zhary@gmail.com\n"
"Language-Team: aThemix\n"
"Language: ru\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_attr__;esc_attr_e;esc_html__;esc_html_e\n"
@a-zhary
a-zhary / JS Cookies
Created October 2, 2019 11:18
set/get/remove cookies
// getCookie(), setCookie(), deleteCookie()
// возвращает cookie если есть или undefined
function getCookie(name) {
var matches = document.cookie.match(new RegExp(
"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
))
return matches ? decodeURIComponent(matches[1]) : undefined
@a-zhary
a-zhary / atx_get_field_by_label
Last active August 23, 2019 11:18
Get gravity forms field by label
// Get Gravity Forms field by label
function atx_get_field_by_label( $form, $label ) {
foreach( $form['fields'] as $field ) {
// debug($field);
if( $field['label'] == $label ) {
return $field;
}
}
return false;
}