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
#!/bin/bash
# sync.params file example.
# REMOTE_DOMAIN="123.123.123.123"
# KEY_FILE="~/.ssh/site.rsa"
# REMOTE_PATH="/var/www/site/"
# LOCAL_PATH="/mnt/c/laragon/www/site"
# REMOTE_URL="https://www.site.org"
# LOCAL_URL="https://site.test"
# SYNC_PLUGINS="elementor-pro wordpress-seo-premium"
@kagg-design
kagg-design / escape-sanitize.php
Created May 29, 2025 14:57
html_entity_decode_deep
/**
* Decode HTML entities in a string.
* Do it cycle to decode all possible entities, including cases like `<`.
*
* @since 1.9.2.3
*
* @param string $html HTML.
* @param int $flags Flags.
* @param string|null $encoding Encoding.
*
@kagg-design
kagg-design / is_gutenberg_active.php
Last active May 27, 2025 17:56
Function to check if Gutenberg is active.
<?php
/**
* Check if Block Editor is active.
* Must only be used after plugins_loaded action is fired.
*
* @return bool
*/
function is_active() {
// Gutenberg plugin is installed and activated.
$gutenberg = ! ( false === has_filter( 'replace_editor', 'gutenberg_init' ) );
@kagg-design
kagg-design / QuForm.php
Last active May 10, 2025 11:49
Akismet check for Quform
/**
* Check Quform data with Akismet.
*
* @param array|mixed $result Result.
* @param Quform_Form $form Form.
*
* @return array
* @noinspection PhpUndefinedFunctionInspection
* @noinspection PhpPossiblePolymorphicInvocationInspection
*/
@kagg-design
kagg-design / prevent-updating-plugins-under-git.php
Last active February 4, 2025 16:22
Prevent updating plugins having a .git folder inside
<?php
/**
* Prevent updating plugins under git.
*
* @param mixed $value Value of site transient.
*
* @return object
*/
function prevent_updating_plugins_under_git( $value ) {
@kagg-design
kagg-design / class-downloader.php
Last active November 1, 2024 17:35
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 / full_list_of_wp_globals.php
Last active July 23, 2024 14:33
Full list of WordPress global variables, extracted from WP Coding Standards
<?php
/**
* List of global WP variables.
*
* @since 0.3.0
* @since 0.11.0 Changed visibility from public to protected.
* @since 0.12.0 Renamed from `$globals` to `$wp_globals` to be more descriptive.
* @since 0.12.0 Moved from WordPress_Sniffs_Variables_GlobalVariablesSniff to WordPress_Sniff
*
* @var array
<?php
class FooClass {
public static function get_instance() {
static $instance;
if ( ! $instance ) {
$variant = 'A';
@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;
<?php
/**
* Error-handler to be used as a mu-plugin.
*
* @package kagg/compatibility
*/
// phpcs:disable Generic.Commenting.DocComment.MissingShort
/** @noinspection PhpIllegalPsrClassPathInspection */
/** @noinspection AutoloadingIssuesInspection */