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 / handyWooFunctions.md
Last active August 17, 2022 19:23
Handy Snippets for WooCommerce

Handy Functions for Manipulating WooCommerce

So far the following areas are covered in this gist:

  • Removing tabs on the product page.
  • Cleaning the WooCommerce loading of scripts/styles on pages with no woo elements.
  • Changing the call order of features on the single product.
  • Removing all WooCommerce called styles.
  • Ajaxifying the cart add
@jackabox
jackabox / wp-thumbnail-from-url.php
Last active July 2, 2021 16:51
generate a post_thumbnail (and upload) from a url.
<?php
function upload_thumbnail($image_url, $postID) {
// Add Featured Image to Post
$upload_dir = wp_upload_dir(); // Set upload folder
$image_data = file_get_contents($image_url); // Get image data
$filename = basename($image_url); // Create image file name
// $filename = strstr($filename, '?', true); // we stripped the cache from instagram
// Check folder permission and define file location
@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.

@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 / _submenuOrder.md
Created September 7, 2016 10:26
WP submenu order rewrite

WP Submenu Order Function

Handy function to rewrite defined submenus

@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']);

{
"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 / footer.scss
Created October 16, 2016 22:30
permanent sticky footer
@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 / 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,
]);