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 / 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 / kagg-shortcuts.php
Last active June 11, 2022 08:32
Open login page by Ctrl+Alt+L. Can be used as a mu-plugin.
<?php
/**
* Add shortcuts.
*
* @return void
*/
function kagg_shortcuts() {
?>
<script>
@kagg-design
kagg-design / add-xdebug-cookie-to-cron-request.php
Last active June 4, 2022 08:36
How to xDebug Cron requests
@kagg-design
kagg-design / class-downloader.php
Last active May 18, 2022 16:41
A class to hide downloadable links and count downloads.
<?php
/**
* Class to hide file download links and count download number.
*
* @package kagg-downloader
*/
namespace GTS\Quote;
/**
@kagg-design
kagg-design / Redirect.php
Created February 3, 2022 09:18
WPML redirect from /?lang= to /lang
<?php
/**
* Redirect class file.
*
* @package wtei-core
*/
namespace WTEICore;
/**
@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 / uasort
Created November 12, 2021 18:25
uasort example
<?php
$arr = [
[ 'foo' => 1, 'bar' => 7, 'den' => 9 ],
[ 'foo' => 11, 'bar' => 4, 'den' => 0 ],
[ 'foo' => 1, 'bar' => 12, 'den' => 6 ],
[ 'foo' => 1, 'bar' => 10, 'den' => 6 ],
];
uasort( $arr, 'cmp' );
@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 / 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 / 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.