Skip to content

Instantly share code, notes, and snippets.

View KnightAlex's full-sized avatar

Alex Knight KnightAlex

  • Devon, United Kingdom
View GitHub Profile
@KnightAlex
KnightAlex / functions.php
Created July 22, 2015 10:26
Echo out SQL queries in WordPress
if ( !defined('SAVEQUERIES') && isset($_GET['debug']) && $_GET['debug'] == 'sql' )
define('SAVEQUERIES', true);
if ( !function_exists('dump') ) :
/**
* dump()
*
* @param mixed $in
* @return mixed $in
**/
@KnightAlex
KnightAlex / functions.php
Last active August 29, 2015 14:24
Add custom styles to the WordPress TinyMCE editor
/* add a a styleselect drop down menu on the second row of the buttons */
function wpb_mce_buttons_2($buttons) {
array_unshift($buttons, 'styleselect');
return $buttons;
}
add_filter('mce_buttons_2', 'wpb_mce_buttons_2');
/*
@KnightAlex
KnightAlex / wp-admin bar CSS fix
Created June 2, 2015 18:13
CSS fix for wp-admin bar, for when body has relative positioning
@media (max-width: 600px) {
html #wpadminbar{top:-46px} /* wp admin bar fix, due to slide-push menu putting a relative position on the body element */
}
<?php
add_filter( 'loop_shop_columns', 'wc_loop_shop_columns', 1, 10 );
/*
* Return a new number of maximum columns for shop archives
* @param int Original value
* @return int New number of columns
*/
function wc_loop_shop_columns( $number_columns ) {
@KnightAlex
KnightAlex / nav pipes
Created February 27, 2015 10:21
Adding vertical pipe between navigation elements
#site-navigation ul li:after {
content: '|';
color: #fff;
font-size: 10px;
line-height: 24px;
float: left;
}
#site-navigation ul li:last-child:after {
content: ' ';
@KnightAlex
KnightAlex / wordpress change category dropdown text
Created February 23, 2015 13:41
Change text for WordPress 'select category' dropdown widget
function ChangeSelectTitle($cat_args){
$cat_args['show_option_none'] = __('My Category');
return $cat_args;
}
add_filter('widget_categories_dropdown_args', 'ChangeSelectTitle');
@KnightAlex
KnightAlex / CSS
Created January 23, 2015 13:52
Full height separator, regardless of which is taller
.thing {
float: left;
width: 50%;
margin: 10px 0;
box-sizing: border-box;
text-align: center;
background: #e0e0e0;
}
.thing--one {
@KnightAlex
KnightAlex / dynamic mobile menu
Last active August 29, 2015 14:11
Toggle mobile menu based on menu going onto 2 lines
//function for showing/hiding mobile menu dynamically
function mobileMenuToggle(){
//get height of menu and auto-detect when it needs to switch to mobile version
var menuHeight = $('#site-navigation').height();
//menu pushed onto 2 lines, hide it and show mobile one
if((isMobile == false) && (menuHeight > 30)){ //EDIT THIS HEIGHT!
//get the current browser width, as once the browser is this width (or wider) again, normal menu will need to kick in.
$('#site-navigation').hide();
$('#mobile').show();
@KnightAlex
KnightAlex / gist:4fc8e575d82529a19dab
Last active August 29, 2015 14:10
Remove iOS/webkit rounded corner nastiness. CSS
-webkit-appearance: none;
border-radius: 0;
-webkit-border-radius: 0;
@KnightAlex
KnightAlex / Placeholder text colour
Created November 5, 2014 15:22
Placeholder text colour
::-webkit-input-placeholder {
color: red;
}
:-moz-placeholder { /* Firefox 18- */
color: red;
}
::-moz-placeholder { /* Firefox 19+ */
color: red;