Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am aaroneaton on github.
  • I am aaroneaton (https://keybase.io/aaroneaton) on keybase.
  • I have a public key whose fingerprint is D1D5 4ACA C40F E038 52C3 4307 F38C 5B43 ED0A E121

To claim this, I am signing this object:

class MyComponent extends React.Component {
...
render() {
return (
<div className="parent">
<div className="child" ref={el => this.targetEl = el}>Content Here</div>
</div>
)
}
...
@aaroneaton
aaroneaton / disable-comments.php
Created January 4, 2017 02:52
Disables comments on all pages
<?php // Remove this line
// Disable comments on all pages
add_action( 'init', function() {
remove_post_type_support( 'page', 'comments' );
}, 100 );
@aaroneaton
aaroneaton / phpspec-setup.php
Last active September 16, 2016 02:58
Using WP_Mock with PhpSpec
<?php
class TodoSpec extends ObjectBehavior {
public function let() {
\WP_Mock::setUp();
}
public function letGo() {
\WP_Mock::tearDown();
}
@aaroneaton
aaroneaton / om-editor.php
Created August 28, 2015 20:20
Allow editors to use the OptinMonster admin area
<?php // Make sure to remove this tag!
// Add this code to your theme's functions.php file.
add_filter( 'optin_monster_api_menu_cap', 'om_allow_editors_in_menu' );
function om_allow_editors_in_menu( $capability ) {
// The default capability is 'manage_options'. We can switch this out with an editor capability.
return 'publish_pages';
// Change the column widths to match your site
@media #{$large-up} {
.content-sidebar .content-sidebar-wrap {
main {
@include grid-column(9);
}
aside.sidebar-primary {
@include grid-column(3);
}
@aaroneaton
aaroneaton / track-optinmonster.js
Created June 15, 2015 15:21
Manually tracking OptinMonster impressions & conversions
$(document).on('OptinMonsterOnShow', function(event, props, object) {
object.trackGoogleAnalytics('ga-[your-optin-slug]', 'impression');
});
$(document).on('OptinMonsterOptinSuccess', function(event, props, object) {
object.trackGoogleAnalytics('ga-[your-optin-slug]', 'conversion');
});
@aaroneaton
aaroneaton / Navigation.php
Last active March 7, 2017 19:10
Using the Zurb Foundation Top Bar with WordPress menus
<?php
class Navigation {
public function __construct() {
// Move the navigation to the header element
remove_action( 'genesis_after_header', 'genesis_do_nav' );
remove_action( 'genesis_site_title', 'genesis_seo_site_title' );
// remove_action( 'genesis_header', )
<script type="text/javascript">
// We want to store a global reference to the proper optin object to make use of tracking methods.
var om_ref;
jQuery(document).ready(function($){
// Gain access once the entire object is loaded.
$(document).on('OptinMonsterLoaded', function(e, props, obj){
// Replace jshdgfgshf with the unique optin slug you want to target.
if ( 'uv7nlvrd513vds1n' == obj.getProp('optin') ) {
om_ref = obj;
}
<?php
add_filter( 'optin_monster_api_output', 'tgm_om_filter_lightbox_by_tag', 10, 4 );
function tgm_om_filter_lightbox_by_tag( $optins, $optin, $fields, $post_id ) {
// If in a particular tag, remove the lightbox.
$cat_exc = 362; // Replace with the tag ID to target.
$slug = 'sjdfhsjakdkg'; // Replace with the unique slug for the lightbox you want to remove.
$tags = wp_get_object_terms( $post_id, 'post_tag', array( 'fields' => 'ids' ) );
foreach ( (array) $tags as $tag_id ) {
if ( $tag_id && $tag_id == $cat_exc && in_array( $slug, $optins ) ) {