Skip to content

Instantly share code, notes, and snippets.

@rosell-dk
rosell-dk / eu_cookie_banner.js
Last active June 4, 2022 15:30 — forked from bavington/eu_cookie_banner.js
Simple EU Cookie Law Banner JavaScript
@maddisondesigns
maddisondesigns / functions.php
Last active February 7, 2024 13:42
WooCommerce Custom Fields for Simple & Variable Products
/*
* Add our Custom Fields to simple products
*/
function mytheme_woo_add_custom_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
// Text Field
@bacoords
bacoords / grab_vimeo_thumbnail.php
Last active January 24, 2024 09:40
Grab a thumbnail of a private (but embeddable) Vimeo video
<?php
/**
* Grab the url of a publicly embeddable video hosted on vimeo
* @param str $video_url The "embed" url of a video
* @return str The url of the thumbnail, or false if there's an error
*/
function grab_vimeo_thumbnail($vimeo_url){
if( !$vimeo_url ) return false;
$data = json_decode( file_get_contents( 'http://vimeo.com/api/oembed.json?url=' . $vimeo_url ) );
@nicomollet
nicomollet / elementorcssinhead.php
Last active December 6, 2022 09:21
Load Elementor styles on all pages in the head to avoid CSS files being loaded in the footer
<?php
/**
* Load Elementor styles on all pages in the head to avoid CSS files being loaded in the footer
*/
function elementor_css_in_head(){
if(class_exists('\Elementor\Plugin')){
$elementor = \Elementor\Plugin::instance();
$elementor->frontend->enqueue_styles();
}
if(class_exists('\ElementorPro\Plugin')){
@yratof
yratof / load.php
Last active January 30, 2023 08:41
ACF Load layouts into flex field
<?php
add_filter( 'acf/load_field/name=flex_layout', __CLASS__ . '::craft_content_layouts' );
static function craft_content_layouts( $field ) {
// Remove the layouts
// that are named in this list
$remove_list = [
'paragraph',
'banner',
@ashokmhrj
ashokmhrj / custom-template-plugin.php
Last active October 21, 2023 13:36
Get Template Part From plugin directory
<?php
/**
* The below function will help to load template file from plugin directory of wordpress
* Extracted from : http://wordpress.stackexchange.com/questions/94343/get-template-part-from-plugin
*/
define('PLUGIN_DIR_PATH','Your-plugin-directory-path');
function ccm_get_template_part($slug, $name = null) {
do_action("ccm_get_template_part_{$slug}", $slug, $name);
@johnbillion
johnbillion / wp_mail.md
Last active January 27, 2024 14:06
WordPress Emails

WordPress Emails

This document lists all the situations where WordPress sends an email, along with how to filter or disable each email.

This documentation has moved here: https://github.com/johnbillion/wp_mail

@rmorse
rmorse / sf-pro-ajax-events.js
Last active December 8, 2022 22:16
Search & Filter Pro - Ajax Events
//detects the start of an ajax request being made
$(document).on("sf:ajaxstart", ".searchandfilter", function(){
console.log("ajax start");
});
//detects when the ajax request has finished and the content has been updated
// - add scripts that apply to your results here
$(document).on("sf:ajaxfinish", ".searchandfilter", function(){
console.log("ajax complete");
//so load your lightbox or JS scripts here again
@galalaly
galalaly / import-variation.php
Created January 13, 2015 23:00
Create WooCommerce variations with PHP
<?php
// In a class constructor
$this->size_tax = wc_attribute_taxonomy_name( 'Size' );
$this->color_tax = wc_attribute_taxonomy_name( 'Color' );
// Insert the main product first
// It will be used as a parent for other variations (think of it as a container)
$product_id = wp_insert_post( array(
@jeremeamia
jeremeamia / build-zip-from-s3.php
Created August 7, 2014 17:40
Create a zip from objects from S3.
<?php
// These are just the basics for how to do this. Notes:
// - Not fully tested.
// - Not suitable for production.
// - May not work well if large ammounts of data.
// - Requires AWS SDK for PHP and http://php.net/manual/en/book.zip.php
require '/path/to/sdk-or-autoloader';