Skip to content

Instantly share code, notes, and snippets.

KAGG Design kagg-design

Block or report user

Report or block kagg-design

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kagg-design
kagg-design / add_admin
Created Apr 26, 2019
Simple mu-plugin to add admin to the site
View add_admin
<?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
*
@kagg-design
kagg-design / kagg_syntaxhighlighter_precode.php
Last active Jan 19, 2019
Due to issue in SyntaxHighlighter Evolved plugin & symbol is output as &amp; what makes code unreadable.
View kagg_syntaxhighlighter_precode.php
<?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 / clear-grp-cron-jobs.php
Created Jan 17, 2019
Clear multiple cron jobs created by Google Reviews Business plugin.
View clear-grp-cron-jobs.php
<?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_get_between.php
Last active Dec 9, 2018
Finds a substring between two strings.
View kagg_get_between.php
<?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 / class-downloader.php
Created Dec 8, 2018
A class to hide downloadable links and count downloads.
View class-downloader.php
<?php
/**
* Class to hide file download links and count download number.
*/
/**
* Class Downloader.
*
* Requires the following table in database:
*
@kagg-design
kagg-design / enqueue-styles-in-order.php
Created Nov 27, 2018
This is an example of loading styles in order, using WordPress dependencies
View enqueue-styles-in-order.php
<?php
// Enqueue style.css (default WordPress stylesheet)
function uni_bauhaus_theme_styles() {
wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/css/font-awesome.min.css', array(), '4.7.0' );
$ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() );
if ( ! ot_get_option( 'uni_google_fonts' ) || empty( $ot_set_google_fonts ) ) {
wp_enqueue_style( 'uni-bauhaus-theme-fonts', uni_bauhaus_theme_fonts_url(), array(), '1.3.5' );
@kagg-design
kagg-design / disable-update-plugins.php
Last active Nov 20, 2018
Disable update of certain plugins.Put this file into /wp-content/mu-plugins/
View disable-update-plugins.php
<?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
*/
View admin-bar-menu-filter.php
<?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 / full_list_of_wp_globals.php
Last active Nov 14, 2018
Full list of WordPress global variables, extracted from WP Coding Standards
View full_list_of_wp_globals.php
<?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
@kagg-design
kagg-design / is_gutenberg_active.php
Last active Jan 27, 2019
Function to check if Gutenberg is active.
View is_gutenberg_active.php
<?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' ) );
You can’t perform that action at this time.