Skip to content

Instantly share code, notes, and snippets.

View andreicnegrea's full-sized avatar

Andrei Negrea andreicnegrea

  • Munich, Germany
View GitHub Profile
<?php
add_action( 'acf/will_remove_unsafe_html', 'acf_enable_detailed_escape_logging_to_php_error_log', 10, 4 );
add_action( 'acf/removed_unsafe_html', 'acf_enable_detailed_escape_logging_to_php_error_log', 10, 4 );
function acf_enable_detailed_escape_logging_to_php_error_log( $function, $selector, $field_object, $post_id ) {
if ( $function === 'the_sub_field' ) {
$field = get_sub_field_object( $selector, true );
$value = ( is_array( $field ) && isset( $field['value'] ) ) ? $field['value'] : false;
} else {
$value = get_field( $selector, $post_id );
}
@andreicnegrea
andreicnegrea / acf-unsafe-html-detection-backtrace.php
Created January 30, 2024 17:23 — forked from lgladdy/acf-unsafe-html-detection-backtrace.php
Print backtrace on the frontend when potentially unsafe HTML is removed
<?php
add_action( 'acf/will_remove_unsafe_html', 'print_backtrace_for_unsafe_html_removal', 10, 4 );
add_action( 'acf/removed_unsafe_html', 'print_backtrace_for_unsafe_html_removal', 10, 4 );
function print_backtrace_for_unsafe_html_removal( $function, $selector, $field_object, $post_id ) {
echo '<h4 style="color:red">Detected Potentially Unsafe HTML Modification</h4>';
echo '<pre>';
debug_print_backtrace();
echo '</pre>';
}
@andreicnegrea
andreicnegrea / wait-global.js
Created July 24, 2020 16:03 — forked from chrisjhoughton/wait-global.js
Wait for a global variable to exist on the page.
var waitForGlobal = function(key, callback) {
if (window[key]) {
callback();
} else {
setTimeout(function() {
waitForGlobal(key, callback);
}, 100);
}
};
@andreicnegrea
andreicnegrea / functions.php
Created June 24, 2020 17:05 — forked from mhull/functions.php
Demonstrates how to pre-populate checkbox fields when using the Gravity Forms plugin for WordPress
<?php
# Make sure to replace {id} with your form's id
add_filter( 'gform_pre_render_{id}', 'my_populate_checkbox' );
function my_populate_checkbox( $form ) {
/**
* Loop through form fields
*
@andreicnegrea
andreicnegrea / webpack.config.js
Created June 22, 2020 07:32 — forked from efalayi/webpack.config.js
Full webpack config file for bootstrap and fontawesome
const autoprefixer = require('autoprefixer');
const webpack = require('webpack');
const path = require('path');
const precss = require('precss');
const TransferWebpackPlugin = require('transfer-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
devtool: 'eval',
@andreicnegrea
andreicnegrea / intercom.js
Created October 23, 2019 16:01 — forked from djfdev/intercom.js
Intercom boot example
class Intercom {
constructor () {
this.interval = setInterval(this.checkBootStatus.bind(this), 100)
this.timeout = setTimeout(() => {
clearInterval(this.interval)
})
}
checkBootStatus () {
if (window.Intercom && window.Intercom.booted) {