Skip to content

Instantly share code, notes, and snippets.

View Patrick64's full-sized avatar
🦆
All good!

Patrick Woodcock Patrick64

🦆
All good!
View GitHub Profile
@Patrick64
Patrick64 / cool.regex
Last active January 27, 2022 11:43
Wicked cool regexs
# Match all script tags
<script(.|\n)*?</script>
# Match all style tags
<style(.|\n)*?</style>
# match all iframes
<iframe(.|\n)*?</iframe>
@Patrick64
Patrick64 / reefine-flexible-filter-groups-example.html
Created December 11, 2013 09:21
Complete example using flexible filter groups This example uses the {number_range_groups} {list_groups} {search_groups} variable pairs and selects the correct html based on the group type. You can add extra fields to this example and they should show up automatically.
{exp:reefine filter:search:fields="title|product_type|colour"
filter:search:type="search" filter:price:fields="price"
filter:price:type="number_range"
filter:fields="product_type|size|colour" channel="clothes"
parse="inward"
url="/{segment_1}/{segment_2}/{product_type}/{size}/{colour}/{price}/{search}/#reefine"
}
<div class="reefine" id="reefine">
<div role="search">
<div class="reefine_search">
@Patrick64
Patrick64 / reefine-seperate-filters-example.html
Created December 11, 2013 09:28
Complete example using separate filters. This example outputs each filter group in a separate tag pair rather than using the {list_groups}, {number_groups} etc. This is useful for customising the order, position and formatting of different filters.
<div class="reefine" id="reefine">
{exp:reefine filter:search:fields="title|product_type|colour"
filter:search:type="search" filter:price:fields="price"
filter:price:type="number_range"
filter:fields="product_type|size|colour|store_availability"
channel="clothes" parse="inward"
url="/{segment_1}/{segment_2}/{product_type}/{size}/{colour}/{store_availability}/{price}/{search}/#reefine"
seperate_filters="yes" }
<div class="reefine_search">
{search} {filters}
@Patrick64
Patrick64 / config.php
Created January 31, 2020 16:26
EE2 config overrides sample
$protocol = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") ? "https://" : "http://";
$site_url = $protocol.$_SERVER['HTTP_HOST'];
$config['tmpl_file_basepath'] = $_SERVER['DOCUMENT_ROOT'] . '/cmsadmin/expressionengine/templates';
$config['share_analytics'] = 'y';
$config['theme_folder_url'] = $site_url . '/themes/';
$config['theme_folder_path'] = $_SERVER['DOCUMENT_ROOT'] . '/themes';
$config['base_path'] = $_SERVER['DOCUMENT_ROOT'];
$config['base_url'] = $site_url; // CHECK this isn't defined below
$config['site_url'] = $site_url;
$config['cp_url'] = $site_url . "/cmsadmin/index.php";
@Patrick64
Patrick64 / wpsitesync-clear-w3-cache-after-push.php
Last active January 30, 2020 09:13
wpsitesync-clear-w3-cache-after-push.php
add_action('spectrom_sync_api_process','clear_cache_after_sitesync_push',10,3);
function clear_cache_after_sitesync_push($action, $response, $apicontroller) {
if ($action==='push_complete' || $action==='push') {
if (function_exists('w3tc_flush_all')) {
w3tc_flush_all();
}
}
}
$config['reesponsive_breakpoints'] = array(0,569,769,1025,1920);
$config['reesponsive_densities'] = array(1,2);
$protocol = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") ? "https://" : "http://";
$site_url = $protocol.$_SERVER['HTTP_HOST'];
$config['theme_folder_url'] = $site_url . '/themes/';
$config['theme_folder_path'] = $_SERVER['DOCUMENT_ROOT'] . '/themes';
$config['base_path'] = $_SERVER['DOCUMENT_ROOT'];
$config['base_url'] = $site_url;
<div class="pie-chart-block">
<?php if (get_sub_field('chart_description')): ?>
<div class="pie-chart-description">
<?= get_sub_field('chart_description'); ?>
</div>
<?php endif; ?>
<?php
function loadMoreButton() {
if ($('.listing-load-more-button').length>0) {
function loadMore(btn) {
var loadingElement = btn.parent().find('.loading');
loadingElement.show();
btn.remove();
var href = btn.attr('href');
$.get(btn.attr('href'),function(data) {
var newItems = /<!\-\-ITEMSBEGIN\-\->(.*)?<!\-\-ITEMSEND\-\->/s.exec(data)[0];
loadingElement.remove();
function smoothAnchorScroll() {
// https://www.abeautifulsite.net/smoothly-scroll-to-an-element-without-a-jquery-plugin-2
$('a[href*="#"]').on('click', function(event) {
if (this.getAttribute('href') == "#") return;
var target = $(this.getAttribute('href'));
if( target.length ) {
// event.preventDefault();
$('html, body').stop().animate({
scrollTop: target.offset().top
}, 1000);
function resizeVideos() {
var $allVideos = $("iframe[src^='https://player.vimeo.com'], iframe[src^='https://www.youtube.com'], object, embed");
$allVideos.each(function() {
$(this)
// jQuery .data does not work on object/embed elements
.attr('data-aspectRatio', this.height / this.width)
.removeAttr('height')
.removeAttr('width');