Skip to content

Instantly share code, notes, and snippets.

View jackabox's full-sized avatar
🛠️
Available for Hire

Jack Whiting jackabox

🛠️
Available for Hire
View GitHub Profile
@jackabox
jackabox / httpd-vhost.conf
Created November 25, 2016 09:38
vhost wildcard for .dev domain
<VirtualHost *:80>
ServerAlias localhost *.dev
VirtualDocumentRoot /Users/%USERNAME%/Sites/websites/%1/public
UseCanonicalName Off
<Directory "/Users/%USERNAME%/Sites/Websites">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Require all granted
@jackabox
jackabox / loop.php
Last active July 11, 2017 12:37
Utilizing WordPress 4.4 responsive images.
<?php if (has_post_thumbnail()): ?>
<?php
$id = get_post_thumbnail_id();
$src = wp_get_attachment_image_src($id, 'full')[0];
$srcset = wp_get_attachment_image_srcset($id, 'full');
$sizes = wp_get_attachment_image_sizes($id, 'full');
$alt = get_post_meta($id, '_wp_attachment_image_alt', true);
?>
@jackabox
jackabox / social_query.php
Created November 3, 2016 14:06
example custom query
<?php
$query = new WP_Query([
'post_type' => ['posts', 'adso_instagram', 'adso_facebook', 'adso_twitter', 'adso_youtube'],
'post_status' => 'publish',
'posts_per_page' => 30,
'orderby' => 'date',
'order' => 'DESC',
'cache_results' => TRUE,
]);
@jackabox
jackabox / queryInKilometers.sql
Created October 30, 2016 15:59
Geo Query / Radius Search
SELECT id, ( 6371 * acos( cos( radians($LAT) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians($LNG) ) + sin( radians($LAT) ) * sin( radians( lat ) ) ) ) AS distance
FROM table_name
HAVING distance < 15
ORDER BY distance
LIMIT 0 , 20;
@jackabox
jackabox / footer.scss
Created October 16, 2016 22:30
permanent sticky footer
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"caret_extra_bottom": 2,
"caret_extra_top": 2,
"caret_extra_width": 2,
"caret_style": "phase",
"color_scheme": "Packages/User/SublimeLinter/Agila Oceanic Next (SL).tmTheme",
"drag_text": false,
"font_face": "Source Code Pro Medium",
@jackabox
jackabox / _defaultSettings.md
Created September 7, 2016 11:42
default options pages used on plugins

Default Settings

The usual settings implemented within plugin files. Here just to speed things up. Implement.

Add $this-&gt;sections = $this-&gt;get_sections(); to __construct, and define add_action('admin_init' [$this, 'register_settings']);

@jackabox
jackabox / _submenuOrder.md
Created September 7, 2016 10:26
WP submenu order rewrite

WP Submenu Order Function

Handy function to rewrite defined submenus

@jackabox
jackabox / _readme.md
Last active October 28, 2019 12:09
Updating Posts/Post Meta when changing WP URL

Updating WP Database Post, Options & Meta

Every now and then you change the site url. You need to make sure you're updating your database references from the old site to the new one and this handly little snippet will help you do that.

Make sure you change 'wp_' to whatever your prefix is set at for your database, update your URLs and then run the commands.

@jackabox
jackabox / WPGeoQuery.md
Last active March 31, 2026 23:38
WordPress Geo Location Query

WP Geo Query

Quick and easy class created to modify the WP_Query on specific calls and pull in all posts within a radius from a given latitude and longitude.