Skip to content

Instantly share code, notes, and snippets.

View paolobortolotti's full-sized avatar

Paolo Bortolotti paolobortolotti

View GitHub Profile
@paolobortolotti
paolobortolotti / date_range.php
Created May 16, 2018 21:40 — forked from morgyface/date_range.php
WordPress | ACF | Simple date range
<?php
function date_span_filter($start_date, $end_date) {
if ( $start_date ) {
// Dates should both be in a Y-m-d format
$start_calendar_date = date('j F Y', strtotime($start_date));
if ( ! $end_date ) {
// There is no range. Just return the required start date
$date = $start_calendar_date;
} else {
if ( $start_date == $end_date ) {
@paolobortolotti
paolobortolotti / gist:b3eaad29cb25d506c3e5f6ce72a6a4ed
Created October 22, 2018 18:51 — forked from mikejolley/gist:2176823
WooCommerce - Show products from current product category (when viewing a single product)
<?php
if ( is_singular('product') ) {
global $post;
// get categories
$terms = wp_get_post_terms( $post->ID, 'product_cat' );
foreach ( $terms as $term ) $cats_array[] = $term->term_id;
@paolobortolotti
paolobortolotti / custom-search-acf-wordpress.php
Created April 5, 2021 09:55 — forked from felthy/custom-search-acf-wordpress.php
PHP - Wordpress - Search - wordpress custom search function that encompasses ACF/advanced custom fields and taxonomies and split expression before request. Updated to use wpdb prepare() and esc_like().
<?php
/*
##############################
########### Search ###########
##############################
Included are steps to help make this script easier for other to follow
All you have to do is add custom ACF post types into Step 1 and custom taxonomies into Step 10
[list_searcheable_acf list all the custom fields we want to include in our search query]
@return [array] [list of custom fields]
@paolobortolotti
paolobortolotti / gist:cf636dbe57cdf2e4f3e873f273b694d3
Created April 15, 2021 12:09 — forked from mikejolley/gist:1604009
WooCommerce - Add a special field to the checkout, order emails and user/order meta
/**
* Add the field to the checkout
**/
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');
function my_custom_checkout_field( $checkout ) {
echo '<div id="my_custom_checkout_field"><h3>'.__('My Field').'</h3>';
/**
@paolobortolotti
paolobortolotti / gutenberg.txt
Created April 5, 2022 15:54 — forked from pmkay/gutenberg.txt
Gutenberg Resources
WordPress Block Development Made Easy
https://webdevstudios.com/2020/06/16/wordpress-block-development/
Using Markdown and Localization in the WordPress Block Editor
https://css-tricks.com/using-markdown-and-localization-in-the-wordpress-block-editor/
Gutenberg blocks: Add custom default class names
https://poolghost.com/add-custom-default-class-names-to-gutenberg-blocks/
How to Create a Simple Gutenberg Block Pattern in WordPress
@paolobortolotti
paolobortolotti / functions.php
Created April 22, 2022 17:49 — forked from yratof/functions.php
ACF OEmbed with thumbnails
<?php
/* Pull apart OEmbed video link to get thumbnails out*/
function get_video_thumbnail_uri( $video_uri ) {
$thumbnail_uri = '';
// determine the type of video and the video id
$video = parse_video_uri( $video_uri );
// get youtube thumbnail
@paolobortolotti
paolobortolotti / .htaccess-headers-target
Created April 26, 2022 20:57 — forked from rayantony/.htaccess-headers-target
content security server configs
##lang
AddDefaultCharset UTF-8
DefaultLanguage en-US
#fix permalinks in woo
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
@paolobortolotti
paolobortolotti / functions.php
Created May 3, 2022 20:18 — forked from jmccall75/functions.php
Locking down Gutenberg...
<?php
//Disable gutenberg style in Front
function jjm_deregister_styles() {
wp_dequeue_style( 'wp-block-library' );
}
add_action( 'wp_print_styles', 'jjm_deregister_styles', 100 );
/**
* Theme Block defaults
*/
@paolobortolotti
paolobortolotti / functions.php
Created December 1, 2022 15:09 — forked from yratof/functions.php
Getting the Video ID from ACF OEmbed, then using that ID to call in videos without bloat
<?php
/* Parse the video uri/url to determine the video type/source and the video id */
function parse_video_uri( $url ) {
// Parse the url
$parse = parse_url( $url );
// Set blank variables
$video_type = '';
$video_id = '';