Skip to content

Instantly share code, notes, and snippets.

View daronspence's full-sized avatar

Daron daronspence

View GitHub Profile
@daronspence
daronspence / acf-ajax.php
Created October 30, 2018 14:20
ACF AJAX for Mike
<?php
add_action('admin_head', function(){
?>
<script type="text/javascript">
/*
updated JS file for use with ACF >= 5.7.0
*/
<?php if( have_rows('partners_logos', $acfw) ): ?>
<?php while( have_rows('partners_logos', $acfw) ): the_row(); ?>
<div class="col-md-6">
<img src="<?php the_sub_field('logo', $acfw); ?>" alt="" class="img-responsive">
</div>
<?php endwhile; ?>
<?php endif; ?>
@daronspence
daronspence / documentation.md
Last active April 11, 2017 06:25
Documentation for basic WordPress Usage

Posts (Blog)

Editing a Post

  • Click on Posts in the left hand menu.
  • Click the title of the post you would like to edit.
  • Make your edits.
  • Click the "Update" button near the top right hand corner.

Update Button

@daronspence
daronspence / count-podcasts.php
Last active December 12, 2016 16:16
Podcast Count Shortcode
<?php
/**
* Plugin Name: Podcast Shortcode
* Description: Adds a shortcode to display your podcast count. <code>[podcast-count]</code>
* Version: 1.0
* Author: Daron Spence
* Author URI: https://daronspence.com/
*
* A simple shortcode to display the number of published podcasts on your site. Uses the `podcast` post type.
*
@daronspence
daronspence / mehTotal.js
Last active August 5, 2016 12:48
Calculate Meh.com Total
// Run this is the JS console of your Browser.
// jQuery must be loaded
// https://meh.com/orders
var total = 0;
$('span.summary').each(function() {
// Get the QTY and Purchase Price
var nums = $(this).text().match(/\d+\.\d+|\d+\b|\d+(?=\w)/g);
// Multiply QTY by Purchase Price
.woocommerce-main-image img { width: 100%; }
img {
width: 100%;
}
.single-product div.product .images .thumbnails a.zoom:focus { outline: none; }
@daronspence
daronspence / .htaccess-new-requests
Created August 2, 2016 02:40
Redirect and preserve POST requests
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_METHOD} GET
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R=307,L]
<?php
$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
@daronspence
daronspence / .htaccess-redirect
Created August 2, 2016 01:59
Same HTTPS .htaccess Redirect
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://yourdomain.com/$1 [R,L]
<?php
// Put this inside of the widget template file for ACFW
// You could also just add this stuff to the template file for your sidebar. Same thing essentially :)
// Note, none of this has been tested! You have been warned! :)
$department = get_user_meta('fire_department', wp_get_current_user()->ID );
$federal_id = get_user_meta('federal_id', wp_get_current_user()->ID );