Skip to content

Instantly share code, notes, and snippets.

@ryelle
ryelle / language.php
Last active September 25, 2018 20:39
Switch the language of the site based on a query param, ex: `site.com/wp-admin?l=en_GB`
<?php
/**
* Plugin: Quick Langauge Switcher
* Note, this only sets the site language, if your user has a user-specific language set, it won't change.
*/
// sv_SE, ja, ko_KR, ar, he_IL
function kdwan_switch_language( $locale ) {
if ( isset( $_GET['l'] ) ) {
return sanitize_key( $_GET['l'] );
}
@ryelle
ryelle / demo.php
Last active November 4, 2015 15:37
Plugin Workshop actions & filters demo plugin
<?php
/*
* Plugin Name: Workshop Demo Plugin
*/
// Action example
function demo_add_html_to_footer() {
echo "<h1 style='color:white;'>I'm an example!</h1>";
}
// add_action( 'wp_footer', 'demo_add_html_to_footer' );
@ryelle
ryelle / infinite-scroll.php
Created October 28, 2015 16:32
Jetpack For Developers: Infinite Scroll example
<?php
function prefix_jetpack_setup(){
add_theme_support( 'infinite-scroll', array(
'type' => 'click',
'container' => 'main',
'posts_per_page' => 12,
'footer' => 'page',
'render' => 'prefix_is_render',
) );
}
@ryelle
ryelle / functions.php
Created April 8, 2015 14:11
Adirondack Child Theme for scrolling infinite scroll
<?php
function adirondack_child_setup() {
add_theme_support( 'infinite-scroll', array(
'type' => 'scroll',
'container' => 'main',
'footer' => 'page',
'posts_per_page' => 12,
) );
}
@ryelle
ryelle / colors.md
Last active August 29, 2015 14:08
Slack Color Schemes

Since there isn't an obvious way to save color schemes, and I switching up often, I'll save my better schemes here. Most likely they'll all be based off ColourLovers/Coolors.co, with help from SassMe.

  1. http://coolors.co/1f9f88-c4d225-ef591c-701943-322b0e

    #322B0E,#292617,#701943,#FFFFFF,#1D1B10,#FFFFFF,#C4D225,#EF591C

@ryelle
ryelle / gist:8639210
Created January 26, 2014 20:41
Regex for finding margins & padding in CSS. Ended up not terribly useful, but interesting?
(padding|margin)(-top|-left|-right|-bottom)?:(\s*(\d*(.\d*)?(em|rem|px|)|auto)){1,4}\s*(!important)?;
<?php
/*
Plugin Name: Color Rotator
Description: Change the color scheme every time you login
Author: Aaron Jorbin
Version: 1.0
Author URI: http://aaron.jorb.in/
License: GPLv2 or later
*/
@ryelle
ryelle / gist:7929316
Created December 12, 2013 14:58
Add an admin color scheme
<?php
wp_admin_css_color(
'vinyard', __( 'Vinyard', 'admin_schemes' ),
plugins_url( "vineyard/colors$suffix.css", __FILE__ ),
array( '#301D25', '#462b36', '#d3995d', '#eabe3f' ),
array( 'base' => '#f1f2f3', 'focus' => '#fff', 'current' => '#fff' )
);
@ryelle
ryelle / admin-icon.php
Created December 3, 2013 16:56
Set up a fake menu item to test using an icon font.
<?php
/**
* Plugin Name: Admin Icon Example
*/
// Add the fake menu item
add_action( 'admin_menu', 'admin_fake_menu_item' );
function admin_fake_menu_item() {
add_menu_page( 'Icon Test', 'Icon Test', 'edit_posts', 'admin-icon-font', '__return_true' );
}
@ryelle
ryelle / mixins.scss
Last active December 27, 2015 14:28
Useful _s SCSS mixins
@mixin clearfix() {
&:before, &:after {
content: "";
display: table;
}
&:after {
clear: both;
}
}