Skip to content

Instantly share code, notes, and snippets.

@jack-arturo
jack-arturo / wpf-all-sites.php
Last active July 12, 2024 00:43
Stores log of all sites that call home looking for updates
<?php
/*
Plugin Name: WPF All Sites
Plugin URI: verygoodplugins.com
Description: Stores log of all sites that call home looking for updates
Version: 1.0
Author: vergoodplugins
Author URI: verygoodplugins.com
License:
@levidavidmurray
levidavidmurray / basecamp-inline-code-styling-userscript.js
Created March 29, 2023 17:42
Basecamp Inline Code Styling Userscript
// ==UserScript==
// @name Inline Code Styling - basecamp.com
// @namespace Violentmonkey Scripts
// @match https://*.basecamp.com/*
// @grant GM_addStyle
// @version 1.0
// @author -
// @description 3/29/2023, 12:42:11 PM
// ==/UserScript==
@danieliser
danieliser / functions.php
Created November 3, 2022 22:41
EDD Subscription Cancellation UX using Gravity Forms & WP Fusion
<?php
/**
* Assumptions:
* - Form ID is #28
* - Page ID is 406200
* - Fields include radio for reason & extra details where needed.
*/
@sabrina-zeidan
sabrina-zeidan / get_acf_block_data.php
Last active April 30, 2024 06:14
Get ACF field value from Gutenberg block [WordPress]
// Get ACF value whetherit comes from regular ACF or ACF block
// Useful if you need to access ACF fileds that are in block as regular fields
// Usage: get_acf_block_data($post, 'acf/talk-description', 'talk_description' )
function get_acf_block_data($post, $block_name = 'acf/default-block-name', $field_name = "" ){
$content = "";
if ( has_blocks( $post->post_content ) && !empty($field_name )) {
$blocks = parse_blocks( $post->post_content );
foreach($blocks as $block){
if ( $block['blockName'] === $block_name ) {
if(isset($block["attrs"]["data"][$field_name ])){
@wpmark
wpmark / php-block-styles.php
Last active November 27, 2024 10:27
Register WordPress block styles with PHP
<?php
/**
* Register some default block editor styles for this block.
*/
function hd_register_block_styles() {
// add the small image style.
register_block_style(
'core/heading', // name of your block
array(
@kajstrom
kajstrom / delete.php
Last active December 5, 2019 19:50
Delete an item from an array without a loop if you don't know the index of the item
$items = [1, 2, 3, 4];
$itemToDelete = 3;
$itemsWithout3 = array_values(array_diff($items, [$itemToDelete]));
//$itemsWithout3 => [1, 2, 4]
add_filter( 'acf/get_valid_field', 'change_post_content_type');
function change_post_content_type( $field ) {
if($field['type'] == 'wysiwyg') {
$field['tabs'] = 'visual'; $field['toolbar'] = 'basic'; $field['media_upload'] = 0;
}
return $field; }
@ffoodd
ffoodd / mu-fSelect.js
Created December 4, 2017 13:27
FacetWP accessibility improvements
(function($) {
$.fn.fSelect = function(options) {
if ('string' === typeof options) {
var settings = options;
}
else {
var settings = $.extend({
placeholder: 'Select some options',
<?php
/*
Plugin Name: GF file upload to ACF image field
Plugin URI: https://gist.github.com/certainlyakey/8c19791b3133beb62d323bf060bf4270
Description: Map Gravity forms file upload field to ACF image/file field so GF would upload the file and save id to DB instead of URL.
Version: 1.0.0
Author: Kellen Mace
*/
@ollietreend
ollietreend / acf-php-to-json.php
Last active February 11, 2025 14:00
Convert Advanced Custom Fields Pro configuration from PHP to JSON.
<?php
/**
* Plugin Name: Convert ACF PHP to JSON
* Description: Convert Advanced Custom Fields Pro configuration from PHP to JSON.
*/
namespace ConvertAcfPhpToJson;
/**
* Add submenu item under 'Custom Fields'