This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Foreach | |
foreach ( $array as $item ) { | |
echo $item; | |
} | |
// Foreach with multi-dimensional array keys | |
foreach ( $array as $key => $item) { | |
echo $key; | |
echo $item; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Search-replace - multisite | |
wp search-replace --network --url=site.company.com site.company.com site.company.dev --precise | |
// Import content to multisite | |
// Look up child site urls | |
wp site list --field=url | |
// Import content, skipping attachments to save time | |
wp import --url="http://site.dev/childsitename/" contentfile.xml --authors=create --skip=attachment | |
// Flush permalinks and rewrite htaccess |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SSH into vagrant box | |
vagrant ssh | |
// Start vagrant | |
vagrant up | |
// Update | |
vagrant provision | |
// Start mysql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Fallback for the object-fit CSS property on IE | |
if ('objectFit' in document.documentElement.style === false) { | |
document.addEventListener('DOMContentLoaded', function () { | |
Array.prototype.forEach.call(document.querySelectorAll('.data-object-fit img'), function (image) { | |
console.log(image.src); | |
(image.runtimeStyle || image.style).background = 'url("' + image.src + '") 50% 50% / cover no-repeat'; | |
image.src = 'data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' width=\'' + image.width + '\' height=\'' + image.height + '\'%3E%3C/svg%3E'; | |
}); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Checkout by hash: | |
git checkout 970327a74bce000242e08b0d6aeaa19ed03add7c | |
// To get back to normal branch: | |
git checkout master | |
// Git log only merges: | |
git log --merges | |
// Remove files from the tree | |
// First add the file name to .gitignore, then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myDog = new Zoo.Dog('Sherlock', 'beagle'); | |
console.log(myDog.bark()); // Sherlock: woof, woof! | |
var myWolf = new Zoo.Wolf('Werewolf'); | |
console.log(myWolf.bark()); // Werewolf: woooooow! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.js-carousel').owlCarousel({ | |
items: 3, | |
margin: 0, | |
stagePadding: 0, | |
nav: false, | |
loop: false, | |
dotsData: false, | |
mouseDrag: false | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Including twig files with vars | |
{% include "button.twig" with { text: "Click me" } %} | |
// Debug (enable WP debugging) | |
{{post|print_r}}// deprecated | |
{{dump(post)}} | |
// Image URL with custom image size | |
{{ TimberImage( fieldname ).src('large') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const myobject = {} | |
myobject[ key ] = value | |
// { key: value } | |
// Add element to array | |
const myarray = [] | |
myarray.push(value1) | |
myarray.push(value2) | |
// [value1,value2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<FilesMatch ".(eot|ttf|otf|woff)"> | |
Header set Access-Control-Allow-Origin "*" | |
</FilesMatch> | |
Header add Access-Control-Allow-Origin "your-domain.com" | |
## To test access-control-allow-headers in terminal: | |
## curl -I https://some.cdn.otherdomain.net/media/fonts/somefont.ttf | |