Skip to content

Instantly share code, notes, and snippets.

View paolobortolotti's full-sized avatar

Paolo Bortolotti paolobortolotti

View GitHub Profile
@jmccall75
jmccall75 / functions.php
Last active January 9, 2024 03:15
Locking down Gutenberg...
<?php
/**
* Gutenberg Block customization for this theme.
*/
// gutenberg disable for posts
//add_filter('use_block_editor_for_post', '__return_false', 10);
// gutenberg disable for post types
//add_filter('use_block_editor_for_post_type', '__return_false', 10);
@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
@pmkay
pmkay / gutenberg.txt
Created November 25, 2020 21:37 — forked from chrismccoy/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 / 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;
@JadedDragoon
JadedDragoon / svg-inliner.php
Last active May 5, 2022 12:29
WordPress filter to convert image tags for locally-hosted SVG files into inline SVG (and thus enabling the SVG to be styled with CSS)
<?php
/*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
@morgyface
morgyface / date_range.php
Created May 11, 2018 15:09
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 ) {
@ashokmhrj
ashokmhrj / hooks.php
Last active January 17, 2024 16:04
WooCommerce mnicart qty update
<?php
add_action('woocommerce_widget_shopping_cart_before_buttons','ask_woo_mini_cart_before_buttons' );
function ask_woo_mini_cart_before_buttons(){
wp_nonce_field( 'woocommerce-cart' );
?>
<div class="submit-button">
<input type="submit" class="button" name="update_cart" value="<?php esc_attr_e('Uppdatera varukorg', 'tidymerch'); ?>"/>
</div>
<?php
@felthy
felthy / custom-search-acf-wordpress.php
Last active April 19, 2021 15:11 — forked from fiskhandlarn/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]
@brojask
brojask / post-listing-shortcode.php
Created December 24, 2015 00:29
Shortcode to List Posts With Multiple Parameters
<?php
/*
Plugin Name: WPTutsPlus Post-listing shortcode
Plugin URI: http://rachelmccollin.co.uk
Description: This plugin provides a shortcode to list posts, with parameters. It also registers a couple of post types and tacxonomies to work with.
Version: 1.0
Author: Rachel McCollin
Author URI: http://rachelmccollin.co.uk
License: GPLv2
*/
@mohandere
mohandere / get-isotope-items.php
Last active March 6, 2024 14:20
jQuery isotope plugin for wordpress posts filtering by category with pagination.
<?php
function get_isotope_item( $query_args = array() ){
$defaults = array(
'post_type' => 'post',
'posts_per_page' => -1,
'post_status' => 'publish',
);