Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

davemac davemac

View GitHub Profile
@davemac
davemac / gist:02b15a021c6eb8972096fa2ee5eacee5
Created Mar 15, 2019
push a local WP database to an existing staging site
View gist:02b15a021c6eb8972096fa2ee5eacee5
# push a local WP database to an existing staging site
# uses current directory as theme path and ssh alias
pushstage() {
START=$(date +%s)
# make a backup of the current local database
# get current directory name, used for database and URL
current=${PWD##*/}
cd ~/Sites/$current || return
# rsync the local database to staging site
@davemac
davemac / gist:532aaa77b11f396a0ef140a6c6c95e0c
Created Mar 14, 2019
pull a production WP database to an existing local site
View gist:532aaa77b11f396a0ef140a6c6c95e0c
# pull a production WP database to an existing local site
# uses current directory as theme path and ssh alias
pullprod() {
START=$(date +%s)
# get current directory name, used for database and URL
# TODO: use echo get_template_directory() and get characters from right to first /
current=${PWD##*/}
cd ~/Sites/$current
# make a backup of the current local database
wp db export _db.sql
@davemac
davemac / cloudflare ips for jetpack
Last active Mar 8, 2019
cloudflare ips for jetpack
View cloudflare ips for jetpack
103.21.244.0-103.21.244.22
103.22.200.0-103.22.200.22
103.31.4.0-103.31.4.22
104.16.0.0-104.16.0.12
108.162.192.0-108.162.192.18
131.0.72.0-131.0.72.22
141.101.64.0-141.101.64.18
162.158.0.0-162.158.0.15
172.64.0.0-172.64.0.13
173.245.48.0-173.245.48.20
View pushstage
# push a local WP database to an existing staging site
# uses current directory as theme path and ssh alias
pushstage() {
START=$(date +%s)
# make a backup of the current local database
# get current directory name, used for database and URL
current=${PWD##*/}
cd ~/Sites/$current || return
# rsync the local database to staging site
View getuploads
# rsync wp uploads directory from staging to current site, exclude .pdf files
# uses command line argument $1 for prod or staging ssh alias
getups() {
current=${PWD##*/}
cd ~/Sites/$current/wp-content/uploads || return
rsync -avzW --progress --exclude '*.pdf' --exclude '*.docx' $current-$1:~/www/wp-content/uploads/* .
}
@davemac
davemac / _dmc-cards.scss
Created Jul 9, 2018
Example css grid card layout
View _dmc-cards.scss
.cards {
display: flex;
align-items: stretch;
justify-content: space-between;
max-width: $row-width;
list-style: none;
margin: 0;
@media #{$medium-up} {
> * {
@davemac
davemac / wpmu change site domain
Created Jun 28, 2018
wpmu change site domain
View wpmu change site domain
# If the sub site's site/home url can not be changed from the WP admin, the following SQL
# queries will change the necessary fields to map a domain to a sub site.
# presuming the sub site ID that we are changing is 1…
UPDATE `wp_blogs` SET domain='smsmagazine.com.au', path='/' WHERE blog_id = 1;
UPDATE `wp_options` SET option_value='https://smsmagazine.com.au/' WHERE option_name='siteurl';
UPDATE `wp_options` SET option_value='https://smsmagazine.com.au/' WHERE option_name='home';
View gist:c150fe755a9879b4077d36ec40e8ed43
// allow editors to manage gravity forms
// allow editors to use Appearance menu
// allow editors to manage co-authors plus plugin, create guest authors
// allow editors to manage Privacy sub-menu under Settings
function dmc_modify_editor_role() {
$role = get_role( 'editor' );
$capabilities = array(
'gform_full_access',
@davemac
davemac / index.html
Created Apr 24, 2018
Responsive Typography for dummies.
View index.html
<hr />
<article class="copy">
<h1>Responsive Typography for dummies</h1>
<pre>h1 {
@include responsive-type(22px, 38px);
}</pre>
<p><strong>A "let the mixin do all the work" approach</strong> to the wonderful <code>calc()</code> liquid and molten text. This is all based off the great work done <a href="https://madebymike.com.au/writing/precise-control-responsive-typography/">by mike</a></p>
<p>Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em></p>
<h2>A Level two header that has a lot of text in it for the molten-lettering and showing off that the <a href="typecast.com/blog/a-more-modern-scale-for-web-typography">line height drops</a> as it gets smaller.</h2>
@davemac
davemac / gist:4f9c6dc52fb53fe2cebdd0fcc2f8e5a1
Created Apr 24, 2018
wp-cli list the page templates used in a site
View gist:4f9c6dc52fb53fe2cebdd0fcc2f8e5a1
wp post list --post_type=page --fields=ID --format=csv | xargs -I % wp post meta get % _wp_page_template
You can’t perform that action at this time.