Skip to content

Instantly share code, notes, and snippets.

View davebonds's full-sized avatar

Dave Bonds davebonds

View GitHub Profile
@davebonds
davebonds / db_update_event_timezones
Created September 6, 2019 21:19
Updates timezone for tribe_events post type
add_action( 'wp_loaded', 'gsandf_update_event_timezones' );
function gsandf_update_event_timezones() {
$args = array(
'posts_per_page' => -1,
);
$events = tribe_get_events( $args );
foreach ( $events as $event ) {
update_post_meta( $event->ID, '_EventTimezone', 'America/New_York');
update_post_meta( $event->ID, '_EventTimezoneAbbr', 'EDT');
@davebonds
davebonds / page-template-usage.php
Last active September 7, 2019 15:56
A WordPress page template to identify what page templates are being used where.
<?php
/*
Template Name: Page Template Usage
Description: A page template to identify what page templates are being used where. BRAAAM
*/
get_header();
// Array of page template name => template filename
$templates = array(
@davebonds
davebonds / wp-update-user.php
Created April 18, 2018 14:50
ManageWP snippet: Finds WP user with specific username and updates their password using wp_insert_user to bypass user notification email
/**
* Gets all users, if username is my_username, updates password with the provided.
*/
function get_users_and_update_info() {
// Build our args for get_users, search for my_username.
$args = array(
'search' => 'my_username',
);
// If multisite, search in the current blog ID (which should be the primary site).

Keybase proof

I hereby claim:

  • I am davebonds on github.
  • I am davebonds (https://keybase.io/davebonds) on keybase.
  • I have a public key ASCuBkpYqJIi3yU3LUR_XCySAuGtrHAAS5RFDdMqvjPK1go

To claim this, I am signing this object:

@davebonds
davebonds / yoast-idx-sitemap-filter.php
Last active October 3, 2018 04:45
Add IDX sitemap to Yoast SEO sitemap
<?php
/**
* Adds IDX sitemap URLs to Yoast's sitemap_index.xml
* Get your individual sitemap URLs by viewing the source of your primary sitemap URL.
* To manually refresh your sitemaps, deactivate sitemaps and reactivate.
* From: https://kb.yoast.com/kb/add-external-sitemap-to-index/
*/
add_filter( 'wpseo_sitemap_index', 'add_idx_sitemap' );
function add_idx_sitemap() {
$idx_sitemap = '
@davebonds
davebonds / equity-webmention.php
Created August 13, 2017 23:18
Add support for webmention to Equity framework
<?php
add_action( 'equity_pings', 'equity_do_webmention' );
/**
* Echo Equity default webmention structure.
*
* Does the `equity_list_args` action.
*
* Applies the `equity_no_webmention_text` filter.
*
* @global WP_Query $wp_query Query object.
<?php
/**
* Add line item for monthly ad budget set by customer.
* Added as $0 - will be adjusted in subscription later based on actual spend.
*
* @param obj $item Passed by reference.
* @param str $cart_item_key Cart key.
* @param arr $values Cart values.
* @param obj $order Order object.
*/
<?php
add_filter( 'woocommerce_add_cart_item_data', 'add_cart_item_data', 10, 2 );
/**
* Add sem-ad-budget field value to the cart item data.
*
* @param array $cart_item_data Data for cart item.
* @param int $product_id The product ID.
*/
public function add_cart_item_data( $cart_item_data, $product_id ) {
global $woocommerce;
jQuery( function() {
jQuery( "#sem-slider-range" ).slider({
range: "max",
min: 0,
max: 1001,
value: 325,
step: 5,
slide: function( event, ui ) {
jQuery( "#sem-ad-budget" ).val( ui.value );
},
<?php
add_action( 'woocommerce_before_add_to_cart_button', 'add_ad_budget_input_field' );
/**
* Output the text input field for #sem_ad_budget - hooked to woocommerce_before_add_to_cart_button().
*
* @return void
*/
public function add_ad_budget_input_field() {
// Bail if not SEM product ID.
if ( !is_single(1234) )