Skip to content

Instantly share code, notes, and snippets.

View fieldoffice's full-sized avatar
🚲
Out cycling

Andy Field fieldoffice

🚲
Out cycling
View GitHub Profile
@fieldoffice
fieldoffice / wordpress-sql-queries
Created December 24, 2014 00:56
WordPress SQL Queries
// UPDATE POST CONTENT
UPDATE wp_posts SET `post_content`
= REPLACE (`post_content`,
'OriginalText',
'ReplacedText');
// CHANGE POSTS TO PAGES
UPDATE wp_posts SET post_type = 'page' WHERE post_type = 'post'
// CHANGE PAGES TO POSTS
@fieldoffice
fieldoffice / ie11-custom-tiles
Created December 28, 2014 15:10
IE11 Custom Tiles
//HEADER
<meta name="msapplication-config" content="browserconfig.xml" />
//ROOT - browserconfig.xml
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="images/smalltile.png"/>
<square150x150logo src="images/mediumtile.png"/>
@fieldoffice
fieldoffice / sass-transforms
Last active September 27, 2022 17:32
Sass Transform Mixins
// Browser Prefixes
@mixin transform($transforms) {
-webkit-transform: $transforms;
-moz-transform: $transforms;
-ms-transform: $transforms;
transform: $transforms;
}
// Rotate
@mixin rotate ($deg) {
@fieldoffice
fieldoffice / prevent-empty-wordpress--search
Created December 30, 2014 16:06
Prevent empty WordPress Search
@fieldoffice
fieldoffice / sass-vertical-align
Last active August 29, 2015 14:13
Sass Vertical Align
@mixin vertical-align {
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
.item p {
@include vertical-align;
@fieldoffice
fieldoffice / card-expiry-year
Created January 12, 2015 19:19
Card Expiry Year
<script type="text/javascript">
var select = $('.card-expiry-year'),
year = new Date().getFullYear();
for (var i = 0; i < 12; i++) {
select.append($("<option value='"+(i + year)+"' "+(i === 0 ? "selected" : "")+">"+(i + year)+"</option>"))
}
</script>
<select class="card-expiry-year"></select>
@fieldoffice
fieldoffice / scroll-to
Created February 4, 2015 18:47
Scroll To
/* TOP - 100 IS THE VERTICAL OFFSET IN PIXELS */
$('#link').click(function() {
$('html, body').animate({
scrollTop: $('#anchor').offset().top - 100
}, 600);
});
@fieldoffice
fieldoffice / google-web-font-loader
Created February 10, 2015 11:15
Google Web Font Loader
<script type="text/javascript">
WebFontConfig = {
google: { families: [ 'Source+Code+Pro::latin' ] }
};
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
@fieldoffice
fieldoffice / sub-menu-wrap
Last active March 18, 2025 18:03
Wordpress - add div wrapper around sub-menu
/* EXTEND SUBNAV
******************************************/
class submenu_wrap extends Walker_Nav_Menu {
function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
$output .= "\n$indent<div class='sub-menu-wrap'><ul class='sub-menu'>\n";
}
function end_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
@fieldoffice
fieldoffice / exporttocsv
Created March 14, 2015 11:20
Export to CSV (MySQL)
<?php
$conn = mysqli_connect('localhost','user','pw') or die(mysqli_error());
$db=mysqli_select_db($conn,'database') or die(mysqli_error());
$filename = 'filename-' . date("d-m-Y") . '.csv';
header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' );
header( 'Content-Description: File Transfer' );
header( 'Content-type: text/csv' );
header( "Content-Disposition: attachment; filename={$filename}" );