Skip to content

Instantly share code, notes, and snippets.

View chris-castillo-dev's full-sized avatar

Chris Castillo chris-castillo-dev

View GitHub Profile
@chris-castillo-dev
chris-castillo-dev / remove-woo-scripts.php
Created February 28, 2020 14:40
Remove Unnecessary WooCommerce Assets
/**
* This code snippet removes JavaScript and CSS files loaded from WooCommerce if they are not necessary.
*
* Please test this on a staging copy of your website before putting this into the functions.php of your live website.
*
* Author: Jan Koch
*/
add_action( 'wp_enqueue_scripts', 'my_remove_woo_assets', 99 );
function my_remove_woo_assets() {
@chris-castillo-dev
chris-castillo-dev / manage-wp-modsec-exclusion.txt
Last active May 11, 2020 20:26
Modsec - Whitelabel ManageWP
# Modify the REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf file located at:
# /etc/nginx/modsec/owasp/rules/
# Add the code block below to the end of your file.
# After saving the .conf file .. don't forget to run the following commands:
# 1. "nginx -t" to test the configuration. If the tests are successful reload the server
# 2. "gp nginx -reload"
SecRule REQUEST_HEADERS:X-Real-IP "@ipMatch 34.211.180.66,54.70.65.107,34.210.224.7,52.41.5.108,52.35.72.129,54.191.137.17,35.162.254.253,52.11.12.231,52.11.29.70,52.11.54.161,52.24.142.159,52.25.191.255,52.34.126.117,52.34.254.47,52.35.82.99,52.36.28.80,52.39.177.152,52.41.237.12,52.43.13.71,52.43.76.224,52.88.96.110,52.89.155.51,54.187.92.57,54.191.32.65,54.191.67.23,54.191.80.119,54.191.135.209,54.191.136.176,54.191.148.85,54.191.149.8,52.26.122.21,52.24.187.29,52.89.85.107,54.186.128.167,54.191.40.136,52.88.119.122,52.89.94.121,52.25.116.116,52.88.215.225,54.186.143.184,52.88.197.180,52.27.171.126,34.211.178.241,52.24.232.158,52.26.187.210,52.42.189.119,54.186.2
@chris-castillo-dev
chris-castillo-dev / enqueue-by-tag.php
Created May 7, 2020 23:59
WordPress - Enqueue by Page Tags
if ( $pageTags = get_the_terms( get_the_ID(), 'post_tag' ) ) {
$pageTagNames = wp_list_pluck( $pageTags, 'name' );
if( in_array( 'slider', $pageTagNames ) ){
wp_enqueue_script( 'pdms-slick', 'https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.js', array( 'jquery' ), '1.9.0', true );
wp_enqueue_style( 'pdms-slick-styles', 'https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.css', '1.9.0', 'all' );
}
}
{"agency_base_standard_classes":{"standard_class_group":[{"group_name":"Breakpoints (Reference Only)","classes":[{"class":"s","description":"Mobile (up to 480px)"},{"class":"m","description":"Mobile (up to 768px)"},{"class":"l","description":"Tablet (up to 992px)"},{"class":"xl","description":"Small Desktop (up to 1400px)"}]},{"group_name":"Columns - Gaps & Grow","classes":[{"class":"c-columns-gap-s","description":"Small columns gap"},{"class":"c-columns-gap-m","description":"Medium columns gap"},{"class":"c-columns-gap-l","description":"Large columns gap"},{"class":"c-columns-gap-xl","description":"Extra large columns gap"},{"class":"c-columns-gap-xxl","description":"Extra-extra large columns gap"},{"class":"c-column-grow","description":"Grow column to second column"},{"class":"c-row-grow","description":"Grow column to second row"}]},{"group_name":"Columns - Desktop","classes":[{"class":"c-columns-6"},{"class":"c-columns-5"},{"class":"c-columns-4"},{"class":"c-columns-3"},{"class":"c-columns-2"},{"class":"c-
/**
* Adds 'Back to top' functionality to an element with the ID 'back-to-top'
* @example
* 1. Create a link-wrapper with ID 'back-to-top'
* 2. Add an icon inside the link-wrapper such as an arrow
* 3. Set position fixed: bottom right
* 4. Set opacity to 0
*/
class BackToTop {
document.addEventListener("DOMContentLoaded", function() {
var lazyBackgrounds = [].slice.call(document.querySelectorAll(".lazy-bg"));
if ("IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype) {
let lazyBackgroundObserver = new IntersectionObserver(function(entries, observer) {
entries.forEach(function(entry) {
if (entry.isIntersecting) {
entry.target.classList.add("bg-visible");
lazyBackgroundObserver.unobserve(entry.target);
}
window.mobileCheck = function() {
let check = false;
(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v
function detectUserInteraction(){document.getElementsByTagName("html")[0].classList.add("js-user-action"),"keydown mouseover touchmove touchstart wheel".split(" ").forEach(function(e){window.removeEventListener(e,detectUserInteraction,!1)})}window.mobileCheck=function(){let e=!1;var o;return o=navigator.userAgent||navigator.vendor||window.opera,(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(o)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|
function propel_add_cwv_code(){
?>
<script>
window.addEventListener('load', function(){
document.getElementsByTagName( 'html' )[0].classList.add('loaded');
});
</script>
<style id="cwv-css">
html body{