Skip to content

Instantly share code, notes, and snippets.

fklein-lu / fk_is_front_end_query.php
Last active Oct 7, 2020
Gutenberg block development helper function to detect whether a block renders on the frontend or the backend
View fk_is_front_end_query.php
* Hackish solution to distinguish between block renders on the front end, and the back end.
* In the admin, the global `$wp_query` does not contain a query. We use this to determine whether a rendering is
* happening on the front end or the back end.
* @return bool Whether we're in the admin or on the front end.
function fk_is_front_end_query() {
fklein-lu / gist:99f69de65e74743c14b8
Created Jun 8, 2015
Code for A Guide to Writing Secure Themes - Part 4: Securing Post Meta
View gist:99f69de65e74743c14b8
function wptrt_add_meta_box() {
add_meta_box( 'wptrt-sample-meta-box', esc_html__( 'WPTRT Sample Meta Box', 'wptrt' ), 'wptrt_print_meta_box', 'post' );
add_action( 'add_meta_boxes', 'wptrt_add_meta_box' );
function wptrt_print_meta_box() {
wp_nonce_field( 'wptrt-post-meta-box-save', 'wptrt-post-meta-box-nonce' );