Skip to content

Instantly share code, notes, and snippets.

View kagg-design's full-sized avatar

Igor at KAGG Design kagg-design

View GitHub Profile
@kagg-design
kagg-design / fix.php
Last active March 26, 2020 11:18
Fix for Gravity Forms Multilingual.
<?php
/**
* @return bool
*/
function woocommerce_gforms_use_ajax_filter() {
return true;
}
add_filter( 'woocommerce_gforms_use_ajax', 'woocommerce_gforms_use_ajax_filter' );
REMOTE_DOMAIN="site.ru"
KEY_FILE="~/.ssh/site-root.rsa"
REMOTE_PATH="/path/to/site_dir/"
LOCAL_PATH="D:/Sites/site/"
REMOTE_URL="https://site.ru"
LOCAL_URL="http://site.test"
AFTER_SYNC_COMMANDS="wp plugin deactivate super-socializer && wp user delete 44903 --yes && add_kagg"
#!/bin/bash
if [ "$OSTYPE" == "linux-gnu" ] && grep -q Microsoft /proc/version; then
WP_PATH=$(wp config path)
else
WP_PATH=$(wp config path 2>/dev/null)
fi
if [[ ! $WP_PATH ]]; then
echo "This is not a WordPress install"
<?php
public function get_element_translations( $element_id, $trid = false, $actual_translations_only = false ) {
$valid_element = $this->maybe_populate_cache ( $element_id, $trid );
if ( $element_id ) {
$res = $valid_element
? ( $actual_translations_only
? $this->filter_for_actual_trans ( $element_id ) : $this->translations[ $element_id ] ) : array();
} elseif ( $trid ) {
$res = isset( $this->trid_groups[ $trid ] ) ? $this->trid_groups[ $trid ] : array();
@kagg-design
kagg-design / functions.php
Last active January 12, 2022 12:00
Fix performance problem with woodmart autoload.
<?php
if( ! function_exists( 'woodmart_autoload' ) ) {
function woodmart_autoload($className) {
global $woodmart_files;
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strripos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
@kagg-design
kagg-design / 1.php
Last active January 11, 2020 16:50
Preemptive cache
<?php
$data = [
'element_data' =>
[
7 =>
[
'translation_id' => '18',
'trid' => '12',
'lang' => 'en',
<?php
require_once 'C:\laragon\www\test\wp-load.php';
echo 'Filling up array...' . "\n";
$size = 10 * 1000;
$cycles = 1000 * 1000;
$array = [];
@kagg-design
kagg-design / sample-rest-output.json
Created November 16, 2019 09:46
Sample rest output
[
{
"id": 217,
"date": "2019-11-14T11:20:23",
"date_gmt": "2019-11-14T08:20:23",
"guid": {
"rendered": "http:\/\/wpml.test\/?page_id=217"
},
"modified": "2019-11-15T12:36:54",
"modified_gmt": "2019-11-15T09:36:54",
@kagg-design
kagg-design / class-multilingual.php
Created October 31, 2019 15:04
Fix performance issue in Jupiter X with WPML and Polylang. Replace code of \CustomizerMultilingual::get_custom_customizer_option
<?php
protected function get_custom_customizer_option() {
static $theme_slug = null;
$current_language = self::get_language();
if ( ! $theme_slug ) {
$theme_slug = get_option( 'template' );
}
$option_prefix = str_replace( '-', '_', $theme_slug );
$option_name = $option_prefix . self::get_option_key() . $current_language;
@kagg-design
kagg-design / gist:7cbda38a3ce76c0502748f8ddbc9bebe
Created September 5, 2019 07:00
Remove current action or filter from plugin
<?php
/**
* Remove current action or filter from plugin
*
* @param string $class_name Class name enqueueing the action.
* @param null $action_name Action name.
*/
function remove_plugin_action( $class_name, $action_name = null ) {
global $wp_filter;