Skip to content

Instantly share code, notes, and snippets.

@jeffreyvr
jeffreyvr / README.md
Created September 4, 2020 09:33
Using wp.editor in widgets

Within your widget, you can include a editor with a textarea and the class custom-widget-wp-editor.

 <textarea id="<?php echo $this->get_field_id( 'header' ); ?>" name="<?php echo $this->get_field_name( 'header' ); ?>" class="custom-widget-wp-editor"><?php echo $header; ?></textarea>

Make sure you include the JS-file within the widgets and customizer view.

/**
@ivo-ivanov
ivo-ivanov / delete-acf-data-after-field-removal.php
Last active August 15, 2024 14:17
Delete all data from WP database when an ACF field is deleted. #wordpress #acf
/*Deleting content when an ACF field is deleted is easy, relatively. Please note that the use of this function cannot be undone and it will erase all traces of content for any ACF field that is deleted.
Please be sure that this is something that you want to do before implementing this and I would strongly suggest that this is only enabled during development and not on a live site. Should a client go into ACF for some reason and delete a field, there is nothing that you’d be able to do to recover form it. */
// this action is run by ACF whenever a field is deleted
// and is called for every field in a field group when a field group is deleted
add_action('acf/delete_field', 'delete_acf_content_on_delete_field');
function delete_acf_content_on_delete_field($field) {
// runs when acf deletes a field
@ouija
ouija / functions.php
Created August 11, 2019 22:49
WooCommerce: Remove checkout field descriptions 'slideUp and hide' animations
<?
// WooCommerce has a stupid function in the ./assets/js/frontent/woocommerce.min.js file that hides/shows the 'description' elements
// for the checkout fields both when there is an onclick event on the document body, and when any field input is clicked.
//
// The offending code for this 'feature' is the following:
// i(document.body).on("click",function(){i(".woocommerce-input-wrapper span.description:visible").prop("aria-hidden",!0).slideUp(250)}),i(".woocommerce-input-wrapper").on("click",function(e){e.stopPropagation()}),i(".woocommerce-input-wrapper :input").on("keydown",function(e){var o=i(this).parent().find("span.description");if(27===e.which&&o.length&&o.is(":visible"))return o.prop("aria-hidden",!0).slideUp(250),e.preventDefault(),!1}).on("click focus",function(){var e=i(this).parent(),o=e.find("span.description");e.addClass("currentTarget"),i(".woocommerce-input-wrapper:not(.currentTarget) span.description:visible").prop("aria-hidden",!0).slideUp(250),o.length&&o.is(":hidden")&&o.prop("aria-hidd
@ChrisLTD
ChrisLTD / recalculate-acf-locations.php
Last active November 22, 2021 15:40 — forked from RadGH/recalculate-acf-locations.php
Update ACF location fields
<?php
// Update google map latitude/longitude after importing, using address
//
// https://support.advancedcustomfields.com/forums/topic/how-to-update-google-map-latitudelongitude-after-importing-using-address/
// https://gist.githubusercontent.com/RadGH/428bd8133c34dae60c0c/raw/fbfb0536abd1afc0fad1d2ed2b51c69304406c78/recalculate-acf-locations.php
//
// INSTRUCTIONS
// 1. Grab the file from this Gist and upload it to your theme.
// 2. Configure the options in the variable $ld_recalc. You MUST set the post type, and set the different field keys (see Finding the Field Key).
// 3. Call the file at the top of your functions.php script using include "recalculate-acf-locations.php";
@ControlledChaos
ControlledChaos / README.md
Last active August 5, 2022 15:00
Add data attributes to WordPress image links for use with Fancybox.

Fancybox Data Attributes to Images & Galleries

WordPress Snippet