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 / 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');
/**
* Set font size so the text fits the width of the container
*/
function setupTitleTextFill(container, textElement) {
// make element inline block and wrap a div so it still does a line break
$(container + " " + textElement).css("display","inline-block").wrap('<div class="title-text-fill-wrapper"></div>');
resizeTitleTextFill(container, textElement);
$(window).resize(function() {
resizeTitleTextFill(container, textElement);
@Patrick64
Patrick64 / response_image.html
Created December 11, 2018 09:33
response_image.html #eecms ce_image
{!--
Template snippet
This tempalte snippet is for making a response image to minimise download size using CE Image.
Usage:
{embed="include/responsive_image" class="div-class" src="{image_url}"}
^ ^ ^
| | |