Skip to content

Instantly share code, notes, and snippets.

@corradomatt
corradomatt / run-wp-cron.sh
Last active September 7, 2018 16:10 — forked from bjornjohansen/run-wp-cron.sh
Run cron on all sites on a server (works with multisite) - Thanks to https://gist.github.com/bjornjohansen/a00a9fee5475c4dadb56
#!/bin/bash
# Copyright © 2018 Matt Barrett - https://github.com/corradomatt
# Special thanks to https://gist.github.com/bjornjohansen/a00a9fee5475c4dadb56
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2,
# as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
HTML_ROOT="/var/www/html"
WP_CLI="/usr/local/bin/wp"
SITES=$(find $HTML_ROOT ! -path $HTML_ROOT -maxdepth 1 -type d -exec echo {} \;)
@corradomatt
corradomatt / MyPost.php
Last active September 20, 2016 21:45
Extending Timber\Post class issues... https://github.com/timber/timber/issues/1197
<?php
class MyPost extends Timber\Post
{
public function __construct()
{
parent::__construct();
}
}
// if an invalid form field has been made valid,
// remove the shouty error highlighting - if a valid
// required field has been made invalid, start shouting
$('input, textarea, select').on('change', function(){
var $input = $(this);
var isRequired = $input.parents('.gfield').is('.gfield_contains_required');
var isValid = $input.is(':valid');
if ( isRequired && isValid ) {
@corradomatt
corradomatt / SassMeister-input.scss
Created June 11, 2015 15:43
Generated by SassMeister.com.
// ----
// libsass (v3.2.4)
// ----
%placeholder {
display: block;
}
.another-test {
background: red;
@corradomatt
corradomatt / SassMeister-input.scss
Created June 11, 2015 15:40
Generated by SassMeister.com.
// ----
// libsass (v3.2.4)
// ----
.another-test {
background: red;
}
%placeholder {
display: block;
<!DOCTYPE html>
<head>
<!--Little CSS fade in -->
<style>
.fadeIn{
-webkit-animation: fade-in 2s ease;
-moz-animation: fade-in ease-in-out 2s both;
-ms-animation: fade-in ease-in-out 2s both;
-o-animation: fade-in ease-in-out 2s both;
@corradomatt
corradomatt / CPT_Columns.php
Created June 1, 2015 18:57
Create custom columns for WordPress Custom Post Types Admin Screen.
<?php
//Based on Ohad Raz - https://en.bainternet.info/custom-post-types-columns/
//Some info:
// The classes read the meta field of the CPT ID and enable the sorting
// Is possible remove other column
// Support 4 type of object natively: Title, Thumbnail, Custom taxonomy, Custom Field
// Add a filter cpt_columns_text_{column_name_id} in Title type
// prefix/suffix values are for all the objects except post_thumb
// New features by Mte90:
@corradomatt
corradomatt / compiler.php
Last active August 29, 2015 14:20 — forked from dovy/compiler.php
<?php
Redux::setSection( $opt_name, array(
'title' => __( 'Text Area', 'redux-framework-demo' ),
'desc' => __( 'For full documentation on this field, visit: ', 'redux-framework-demo' ) . '<a href="http://docs.reduxframework.com/core/fields/textarea/" target="_blank">http://docs.reduxframework.com/core/fields/textarea/</a>',
'id' => 'opt-textarea-subsection',
'subsection' => true,
'fields' => array(
array(
'id' => 'background-parallax',

First time server setup

  • Prerequisites: Git, Ruby, WP-CLI, Node.JS, NPM, Bower, Sass, Gulp, Grunt (Grunt as a backup)

Set up Wordpress using WP-CLI

mkdir project.com.au
cd project.com.au/
wp core download
mysql -u [mysql-username] -p
# Enter MySQL password
@corradomatt
corradomatt / 0_reuse_code.js
Last active August 29, 2015 14:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console