To make things simple, we're going to make a semi-structured way to display a mailing address.
We're going to start with a file tree that looks like this:
address-block
├ blocks
| ├ address.jsx
<?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>'; | |
} |
// listen for all clicks on anything. You could change document to a selector like #content to make it more efficient. | |
$(document).on('click', function( e ) { | |
// if this is a link, and the href does not contain our domain, it's an external link. Track it. | |
if( e.target.href && e.target.href.indexOf( window.location.hostname ) < 0 ) { | |
ga('send', 'event', { | |
eventCategory: 'Outbound Link', | |
eventAction: 'click', | |
eventLabel: e.target.href, // the outbound link url will appear as the event label in GA. Find under Behavior -> Events -> Event Label | |
transport: 'beacon' // not supported in some versions of IE | |
}); |
<?php | |
/** | |
* Enable unfiltered_html capability for Editors. | |
* | |
* @param array $caps The user's capabilities. | |
* @param string $cap Capability name. | |
* @param int $user_id The user ID. | |
* @return array $caps The user's capabilities, with 'unfiltered_html' potentially added. | |
*/ |
/* | |
* The Events Calendar Remove Events from Month and List Views | |
* add coding to theme's functions.php | |
* @version 3.12 | |
* modify here with event category slugs: array( 'concert', 'convention' ) | |
*/ | |
add_action( 'pre_get_posts', 'tribe_exclude_events_category_month_list' ); | |
function tribe_exclude_events_category_month_list( $query ) { | |
if ( isset( $query->query_vars['eventDisplay'] ) && ! is_singular( 'tribe_events' ) ) { |
<?php | |
# http://kovshenin.com/2012/the-wordpress-settings-api/ | |
# http://codex.wordpress.org/Settings_API | |
add_action( 'admin_menu', 'my_admin_menu' ); | |
function my_admin_menu() { | |
add_options_page( __('My Plugin Options', 'textdomain' ), __('My Plugin Options', 'textdomain' ), 'manage_options', 'my-plugin', 'my_options_page' ); | |
} | |
add_action( 'admin_init', 'my_admin_init' ); |