Skip to content

Instantly share code, notes, and snippets.

View stirtingale's full-sized avatar

Stirtingale stirtingale

View GitHub Profile
@stirtingale
stirtingale / block-file.php
Last active August 24, 2022 20:34
Limit ACF field to edit only
<?php
if (isset($block['data']['preview_image_help'])):
$image = get_template_directory_uri() . '/blocks/previews/' . basename(__FILE__, '.php') . '.png';
echo '<img src="' . $image . '" style="width:100%; height:auto;">';
else:
?>
Front End Content
<?php
endif; // preview_image_help
?>
@stirtingale
stirtingale / wp-tinyMCE4.php
Created July 15, 2022 15:33 — forked from martylouis/wp-tinyMCE4.php
A custom WordPress TinyMCE v4 configuration with styles (now called "Formats") drop down menu and submenus.
<?php
/**
* TinyMCE v4 Config
*
* A custom WordPress TinyMCE v4 configuration with styles (now called "Format") drop down menu with submenus.
*
* style_formats: http://www.tinymce.com/wiki.php/Configuration:style_formats
*
*/
@stirtingale
stirtingale / flex.liquid
Created February 9, 2022 13:48
Shopify Flex Image Ratio
<div class="flex-image" style="padding-bottom: {{ 1 | divided_by: section.settings.image.aspect_ratio | times: 100 }}%;"
>
@stirtingale
stirtingale / product-snippet.liquid
Created July 8, 2021 10:22
Return flex / responsive image in Shopify Liquid
{% assign width = product.featured_image.width | times: 1.00 %}
{% assign height = product.featured_image.height | times: 10000.00 %}
{% assign padding = height | divided_by: width | divided_by: 100 %}
<div class="flex-image fit --zoom" style="padding-bottom:{{padding}}%">
<img class="lazy" data-src="{{ product.featured_image | img_url: '450x' }}" alt="{{ link.title }}">
</div>
@stirtingale
stirtingale / burger.js
Created July 23, 2020 12:04
React Component Based on 'Tasty CSS-animated hamburgers' @ https://jonsuh.com/hamburgers/
class Burger extends React.Component {
constructor(props) {
super(props);
this.state = {addClass: false}
}
toggle() {
this.setState({addClass: !this.state.addClass});
}
render() {
let burderClass = ["hamburger hamburger--collapse"];
@stirtingale
stirtingale / single.php
Last active March 2, 2020 10:55
Get next post in current URL category Wordpress
<?php
// BASED ON @ https://wordpress.stackexchange.com/questions/149826/display-posts-from-the-same-category-using-next-previous-post-link
$post_id = $post->ID; // current post ID
$cat = get_the_category();
$current_cat_id = $cat[0]->cat_ID; // current category ID
$cat_id = get_queried_object_id();
// GET CAT FROM URL
// this is hacky as hell.
$current_url = home_url( add_query_arg( array(), $wp->request ) );
@stirtingale
stirtingale / sync.sh
Created June 3, 2019 08:45
Sync DB Script
#!/bin/bash
#
#
SITELIST=~/dbbackup/sitelist-wp-sites.sdata
find ~/public_html -type f -name wp-config.php -print > ${SITELIST}
while read LINE
do
@stirtingale
stirtingale / nightly.sh
Created June 3, 2019 08:38
Nightly Database Backup Script
#!/bin/bash
#
#
BACKUPPATH=~/dbbackup/sql
SITELIST=~/dbbackup/sitelist-wp-sites.sdata
#
# Common Logging Code
#
@stirtingale
stirtingale / functions.php
Last active May 16, 2019 08:33
Add Netlify Hook for FORMIDABLE Wordpress forms ( Useful if using Netlify as static fallback )
// FORMIDABLE NETFLIY HOOK
add_filter( 'frm_form_attributes', 'add_custom_form_attributes', 10, 2 );
function add_custom_form_attributes( $attributes, $form ){
$attributes .= 'data-netlify="true"';
return $attributes;
}
@stirtingale
stirtingale / convert-content-to-fields.php
Created April 11, 2019 08:22
Wordpress Post Content to Caption and Gallery Field ACF
<?php
// vars
$post_id = get_the_id();
$images = get_field('gallery');
$caption = get_field('caption');
$content = get_the_content();
// var_dump($post_id);