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 / is_gutenberg_active.php
Last active January 27, 2019 21:18
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 / full_list_of_wp_globals.php
Last active April 2, 2024 06:34
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
/**
* Change site url in admin bar
*
* @param WP_Admin_Bar $wp_admin_bar
*/
function admin_bar_menu_filter( WP_Admin_Bar $wp_admin_bar ) {
$new_url = 'site.org';
$site_name_node = $wp_admin_bar->get_nodes()['site-name'];
$site_name_node->href = $new_url;
@kagg-design
kagg-design / disable-update-plugins.php
Last active November 20, 2018 12:56
Disable update of certain plugins.Put this file into /wp-content/mu-plugins/
<?php
/**
* Plugin Name: Disable updates plugins
* Plugin URI: https://kagg.eu/en/
* Description: Disable update of certain plugins.
* Version: 1.0
* Author: KAGG Design
* Author URI: https://kagg.eu/en/
* License: GPL2
*/
@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 / kagg_get_between.php
Last active December 9, 2018 11:32
Finds a substring between two strings.
<?php
/**
* Finds a substring between two strings.
*
* @param string $string The string to be searched
* @param string $start The start of the desired substring
* @param string $end The end of the desired substring
* @param bool $greedy Use last instance of`$end` (default: false)
*
@kagg-design
kagg-design / clear-grp-cron-jobs.php
Created January 17, 2019 17:40
Clear multiple cron jobs created by Google Reviews Business plugin.
<?php
/**
* Clear multiple cron jobs created by Google Reviews Business plugin.
*/
function clear_cron_jobs() {
$crons = _get_cron_array();
$hook = 'grp_auto_save';
$args_array = array();
$new_cron = array();
foreach ( $crons as $timestamp => $cron ) {
@kagg-design
kagg-design / kagg_syntaxhighlighter_precode.php
Last active September 6, 2019 08:21
Due to issue in SyntaxHighlighter Evolved plugin & symbol is output as &amp; what makes code unreadable.
<?php
/**
* Filter to fix issue in SyntaxHighlighter Evolved plugin.
*
* @param string $code Code to format.
* @param array $atts Attributes.
* @param string $tag Tag.
*
* @return string
*/
@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 / add_admin
Created April 26, 2019 08:45
Simple mu-plugin to add admin to the site
<?php
/**
* Plugin Name: Add Admin
* Plugin URI: https://kagg.eu/en/
* Description: Add admin to the WordPress site.
* Version: 1.0
* Author: KAGG Design
* Author URI: https://kagg.eu/en/
* License: GPL2
*