Skip to content

Instantly share code, notes, and snippets.

@GrindPress
GrindPress / get_stores_by_location.php
Created April 21, 2017 04:47 — forked from daltonrooney/get_stores_by_location.php
Store locator with Advanced Custom Fields
<?php
function mbn_get_stores_by_location( $zip, $radius ) {
global $wpdb;
$radius = intval( $radius );
// we first need to get the source coordinates
$sql = "SELECT `latitude`, `longitude` FROM `wp_zip_codes` WHERE `zipcode` = '%s'";
$coords = $wpdb->get_row( $wpdb->prepare( $sql, $zip ) );
@GrindPress
GrindPress / gist:a5d36cd3fb783b4691877a107c9f3509
Created April 13, 2017 19:02 — forked from hissy/gist:6822610
[WordPress/ACF] example of import values to repeater field
<?php
$value = array(
array(
'text' => 'text',
'image' => 1
),
array(
'text' => 'text2',
'image' => 2
)
"post_title","post_type","lat","lng"
"Map","post",35.710115,139.810203
@GrindPress
GrindPress / feed-offset
Created April 8, 2017 19:47 — forked from mathetos/feed-offset
WordPress Custom RSS Feed with Offset
<?php
/**
* RSS2 Feed Template for displaying RSS2 Posts feed.
* Adds an offset of "1" to display all but most recent
* Full details at: https://wordimpress.com/anatomy-advanced-wordpress-blog-notification-email
* @package WordPress
*/
header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
$more = 1;
@GrindPress
GrindPress / functions.php
Created January 6, 2017 20:20
Connect Gravity Forms to Engaging Networks API
<?php
/**
* Integrate Gravity Forms with Engaging Networks
*
*/
function gp_en_connector( $entry, $form ) {
if ( isset($entry['14']) ) // Using a hidden form field now, but would like to use a custom for setting instead.
{
$fields['format'] = 'json';
@GrindPress
GrindPress / _wp-classes.scss
Last active April 2, 2016 15:45
Fix for overlapping WP-admin bar and Bootstrap fixed navbar
/*
**
* Fix for overlapping WP-admin bar and Bootstrap fixed navbar
*
----------------------------------------------------------*/
body.admin-bar .navbar-fixed-top {
position:fixed;
top: 46px;
z-index: 1000;
}
@GrindPress
GrindPress / extras.php
Last active March 31, 2016 15:14
Move Yoast SEO box to bottom of edit page
<?php
/**
* => Move Yoast SEO box to bottom of page
*
*-------------------------------------------------- */
function yoasttobottom() {
return 'low';
}
add_filter( 'wpseo_metabox_prio', __NAMESPACE__ . '\\yoasttobottom');
@GrindPress
GrindPress / extras.php
Created March 31, 2016 15:11
Hide ACF menu except for specified users
<?php
/***
* => Hide ACF menu except for specified users
*
--------------------------------------------------- */
function gp_acf_show_admin( $show ) {
$current_user = wp_get_current_user();
@GrindPress
GrindPress / main.js
Created September 19, 2015 17:35
Bootstrap accordion scroll to top of active panel heading
/**
Bootstrap accordion scroll to top of active panel heading
http://stackoverflow.com/a/29195062/1241535
----------------------------------------------*/
$('#accordion').on('shown.bs.collapse', function (e) {
var offset = $(this).find('.collapse.in').prev('.panel-heading');
if(offset) {
$('html,body').animate({
scrollTop: $(offset).offset().top -100
}, 500);
@GrindPress
GrindPress / header.php
Last active August 29, 2015 14:21 — forked from retlehs/header.php
<?php
// This file assumes that you have included the nav walker from https://github.com/twittem/wp-bootstrap-navwalker
// somewhere in your theme.
?>
<header class="banner navbar navbar-default navbar-static-top" role="banner">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only"><?= __('Toggle navigation', 'sage'); ?></span>