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 / remote-post-with-files.php
Created April 7, 2021 15:47
Example of how to send files to the remote server.
$boundary = str_repeat( '-', 24 ) . wp_generate_password( 16 );
$headers = array(
'content-type' => 'multipart/form-data; boundary=' . $boundary,
);
if ( ! isset( $files['path'] ) ) {
$error_message = 'Invalid arguments';
return array( $success, $error_message, $word_count, $individual_word_count );
}
@kagg-design
kagg-design / fix-authors-bug-5.7.php
Created March 22, 2021 08:28
MU-Plugin to temporary fix the problem with the list of authors on post edit page with Block Editor.
<?php
/**
* MU-Plugin to temporary fix the problem with the list of authors on post edit page with Block Editor.
* With WP 5.7, user with the Editor role is unable to search across long list of authors in Author combobox.
*
* @package kagg-design
*/
/**
* Fixes bug in WP 5.7 with author selection on post edit in admin.
@kagg-design
kagg-design / cyr2lat-attributes-in-woocommerce.php
Created March 20, 2021 14:01
MU Plugin to block transliteration of WooCommerce attributes and attribute terms.
<?php
/**
* MU Plugin to block transliteration of WooCommerce attributes and attribute terms.
*
* @package cyr-to-lat
*/
/**
* Class Block_WC_Attr_Cyr2lat.
*/
@kagg-design
kagg-design / disable-update-plugins.php
Last active July 19, 2022 15:46
Disable update plugins mu-plugin
<?php
/**
* Plugin Name: Disable updates plugins
* Plugin URI: https://kagg.eu/en/
* Description: Disable update of certain plugins.
* Version: 1.2
* Author: KAGG Design
* Author URI: https://kagg.eu/en/
* License: GPL2
*
@kagg-design
kagg-design / block-login.php
Last active June 23, 2020 14:32
Block any kind of logins to the site
<?php
/**
* Plugin Name: Block Login
*/
function no_login_authenticate_filter( $user, $username, $pass ) {
remove_filter( 'authenticate', 'wp_authenticate_username_password', 20, 3 );
return null;
}
@kagg-design
kagg-design / att.php
Created June 23, 2020 11:58
Mail attachment missing
<?php
add_action( 'init', 'att_page', PHP_INT_MAX );
function att_page() {
if ( is_att_page() ) {
$attachment = null;
$to = 'info@kagg.eu';
$subject = 'subj';
$message = 'message';
include_once ABSPATH . 'wp-admin/includes/file.php';
jQuery( document ).ready(
function( $ ) {
var timer;
var logAjax = 0;
var $nonce = $( '#gts_webtranslator_gateway_nonce' ).val();
var $progressBarWrap = $( '#progress-bar-wrap' );
var $progressDot = $( '#progress-dot' );
var $progressCount = $( '#progress-count' );
var $progressBar = $( '#progress-bar' );
var $logElement = $( '#webtranslator-log' );
@kagg-design
kagg-design / functions.php
Created April 25, 2020 08:31
wc1c hooks
<?php
/**
* wc1c_import_product_xml hook
* Prevent processing a product if there is no product in database with same SKU.
* If product with the same SKU found in the db, update _wc1c_guid option to allow product update.
*
* @param array $product
* @param bool $is_full
*
* @return null|array
<?php
use Cyr_To_Lat\Cyr_To_Lat_TestCase;
class Krya {
public function init() {
$overload = new Krya_Overload();
add_action( 'over', [ $overload, 'over_func' ] );
}
<?php
/**
* @author OnTheGo Systems
*/
class GFML_Conditional_Logic extends GFML_Form {
/**
* It translates the attributes of the conditional logic, before translating the fields.
* This is necessary, or it would not be possible to adjust the conditional logic based on values from "choices" fields.
*