Skip to content

Instantly share code, notes, and snippets.

View pbrocks's full-sized avatar

Paul Barthmaier pbrocks

View GitHub Profile
@phpbits
phpbits / api.js
Created October 3, 2018 06:35
Use withSelect instead of withAPIData
const { apiFetch } = wp;
const { registerStore, withSelect } = wp.data;
const actions = {
setUserRoles( userRoles ) {
return {
type: 'SET_USER_ROLES',
userRoles,
};
},
@tomjn
tomjn / securing-acf.php
Created July 2, 2018 11:44
ACF's `the_field` function is insecure by default, here's a selection of wrappers that fix that
<?php
function the_field_url( $selector, $post_id=0, $format_value=true ) {
echo esc_url( get_field( $selector, $post_id, $format_value ) );
}
function the_field_url_raw( $selector, $post_id=0, $format_value=true ) {
echo esc_url_raw( get_field( $selector, $post_id, $format_value ) );
}