Skip to content

Instantly share code, notes, and snippets.

View davemac's full-sized avatar

davemac davemac

View GitHub Profile
@davemac
davemac / acf-js.js
Created March 21, 2017 04:43 — forked from neilgee/acf-js.js
ACF Google Map - Get Directions Link
(function($) {
/*
* new_map
*
* This function will render a Google Map onto the selected jQuery element
*
* @type function
* @date 8/11/2013
* @since 4.3.0
@davemac
davemac / acf-first-row.php
Created March 21, 2017 04:46 — forked from neilgee/acf-first-row.php
ACF Repeater - Grab First/LAst or Random Single Data Row
<?php
//My ACF Fields for reference
//testimonials - field group
//testimonial - sub-field
//testimonial_header - sub-field
//First Repeater Row in Array
$rows = get_field( 'testimonials', 348 );// grab all rows from page ID
@davemac
davemac / acf_slick.php
Created May 8, 2017 11:48 — forked from mattradford/acf_slick.php
ACF slick slider
<?php if( have_rows('billboard') ): ?>
<div class="billboard">
<?php while( have_rows('billboard') ): the_row();
$imageArray = get_sub_field('image');
$imageURL = $imageArray['url'];
?>
<div class="slide-item" style="background-image: url('<?php echo $imageURL;?>');" >
<h1><?php the_sub_field('title'); ?></h1>
</div>
<?php
/* Thanks to http://steindom.com/articles/shortest-php-code-convert-csv-associative-array */
ini_set('auto_detect_line_endings', TRUE);
$rows = array_map('str_getcsv', file('myfile.csv'));
$header = array_shift($rows);
$csv = array();
foreach ($rows as $row) {
@davemac
davemac / nginx-redirect-uploads-to-production
Last active August 9, 2023 04:51 — forked from iansvo/nginx-redirect-uploads-to-production
Open the Nginx configuration for your site and look for a server block that listens for port 443. Look for something like Listen 127.0.0.1:443 ssl in the server { ... } block to find the right one. Add the following location rules near the top of the block, after any other definitions.
# Redirect requests to /wp-content/uploads/* to production
set $production themotoringnetwork.com.au;
location @prod_uploads {
rewrite "^(.*)/wp-content/uploads/(.*)$" "https://$production/wp-content/uploads/$2" break;
}
# Rule for handling local requests for images
location ~ "^/wp-content/uploads/(.*)$" {
try_files $uri @prod_uploads;