Skip to content

Instantly share code, notes, and snippets.

View kwsim539's full-sized avatar

Kenneth Sim kwsim539

View GitHub Profile

Scss snippet added inline in admin footer to update WPcoedbox folder and snippet styles, and add a different color background to cloud snippets

The WordPress Codex offers an interesting snippet for a shortcode. First copy the following code into the functions.php of the theme or use WP Code Box:

function wpcodex_hide_email_shortcode( $atts , $content = null ) {
	if ( ! is_email( $content ) ) {
		return;
	}

	return '<a href="mailto:' . antispambot( $content ) . '">' . antispambot( $content ) . '</a>';
}
@matteo-greco
matteo-greco / override-acss-settings.php
Created November 15, 2022 18:44
Override ACSS settings
<?php
$metabox_group_id = 50;
add_action( "rwmb_{$metabox_group_id}_after_save_post", function( $object_id ) {
// STEP: get the variables we want to override from the settings page.
$primary = rwmb_meta( 'test_primary_color', ['object_type' => 'setting'], 'test_client_dashboard');
error_log( sprintf( '%s: primary %s', 'my action handler', $primary ) );
$new_vars = array(
'color-primary' => $primary
);
@bjornjohansen
bjornjohansen / maintenance.php
Created August 31, 2017 11:57
Custom WordPress maintenance mode page
<?php
wp_load_translations_early();
$protocol = wp_get_server_protocol();
header( "$protocol 503 Service Unavailable", true, 503 );
header( 'Content-Type: text/html; charset=utf-8' );
header( 'Retry-After: 30' );
?>
<!DOCTYPE html>
<html>
@zuhairkareem
zuhairkareem / search_partial_string_array.php
Last active June 24, 2024 19:54
Search partial string in an array in PHP
<?php
/**
* First Method.
*/
function array_search_partial($arr, $keyword) {
foreach($arr as $index => $string) {
if (strpos($string, $keyword) !== FALSE)
return $index;
}
}
@iamravenous
iamravenous / jquery.smooth-scroll-pageload.js
Last active April 23, 2024 09:05
Smooth scrolling on page load if URL have a hash
/*
* Smooth Scroll on Pageload
* Smooth scrolling on page load if URL have a hash
* Author: Franco Moya - @iamravenous
*/
if (window.location.hash) {
var hash = window.location.hash;
if ($(hash).length) {
@HoundstoothSTL
HoundstoothSTL / anchor-scroll-with-offset.js
Created May 3, 2013 15:43
Anchor scroll with fixed header offset
(function($) {
$('a[href*=#]:not([href=#])').click(function()
{
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
|| location.hostname == this.hostname)
{
var target = $(this.hash),
headerHeight = $(".primary-header").height() + 5; // Get fixed header height