Skip to content

Instantly share code, notes, and snippets.

View apsolut's full-sized avatar
🎯
Focusing

Aleksandar Perisic apsolut

🎯
Focusing
View GitHub Profile
@apsolut
apsolut / functions.php
Created December 23, 2015 15:59 — forked from kloon/functions.php
WooCommerce set tax exemption based on user role
<?php
add_filter( 'init', 'wc_tax_exempt_user_roles' );
function wc_tax_exempt_user_roles() {
if ( ! is_admin() ) {
global $woocommerce;
if ( current_user_can('wholesaler') || current_user_can('distributor') ) {
$woocommerce->customer->set_is_vat_exempt(true);
} else {
$woocommerce->customer->set_is_vat_exempt(false);
}
@apsolut
apsolut / gist:5a3e55528a66161ffcfe
Created January 6, 2016 18:51 — forked from getdave/gist:4578295
Gravity Forms - custom field validation function for checkboxes. Ensures all checkboxes have been checked.
// Replace 7 with the ID of your form and 13 with the ID of the field you want to force "all required"
// http://www.gravityhelp.com/documentation/page/Gform_field_validation
add_filter("gform_field_validation_7_13", 'validate_tcs', 10, 4);
function validate_tcs($result, $value, $form, $field) {
// Convert the checkbox input name value (returned as part of "field")
// into the "underscored" ID version which is found in the $_POST
foreach ($field['inputs'] as $input) {
$input_post_value = 'input_' . str_replace('.', '_', $input['id']);
@apsolut
apsolut / wp_migrate.md
Created May 4, 2016 16:12 — forked from messified/wp_migrate.md
WordPress DB Migration Queries

Useful WordPress Queries

Site / Home URLs

UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com') WHERE option_name = 'home' OR option_name = 'siteurl';

Update content Guid

@apsolut
apsolut / styles.css
Created April 14, 2017 18:26 — forked from pburtchaell/styles.css
VH and VW units can cause issues on iOS devices. To overcome this, create media queries that target the width, height, and orientation of iOS devices.
/**
* VH and VW units can cause issues on iOS devices: http://caniuse.com/#feat=viewport-units
*
* To overcome this, create media queries that target the width, height, and orientation of iOS devices.
* It isn't optimal, but there is really no other way to solve the problem. In this example, I am fixing
* the height of element `.foo` —which is a full width and height cover image.
*
* iOS Resolution Quick Reference: http://www.iosres.com/
*/
@apsolut
apsolut / WordPress Poedit keywords
Last active July 11, 2017 16:28
WordPress Poedit keywords
__
_e
__ngettext:1,2
_n:1,2
__ngettext_noop:1,2
_n_noop:1,2
_c,
_nc:4c,1,2
_x:1,2c
_ex:1,2c
@apsolut
apsolut / useScrollDirection.js
Created May 21, 2020 13:11 — forked from reecelucas/useScrollDirection.js
React hook to detect scroll direction, based on the API of https://github.com/dollarshaveclub/scrolldir
const SCROLL_UP = "up";
const SCROLL_DOWN = "down";
const useScrollDirection = ({
initialDirection,
thresholdPixels,
off
} = {}) => {
const [scrollDir, setScrollDir] = useState(initialDirection);
@apsolut
apsolut / acf_image_to_featured_image.php
Created May 26, 2020 09:20 — forked from morgyface/acf_image_to_featured_image.php
WordPress | Set ACF image to be the WP feature image
@apsolut
apsolut / yoast_seo_breadcrumb_remove_link.php
Created July 17, 2020 16:37 — forked from amboutwe/yoast_seo_breadcrumb_remove_link.php
Remove link from the Yoast SEO breadcrumbs site wide
@apsolut
apsolut / yoast_seo_breadcrumb_add_woo_shop.php
Created July 17, 2020 16:44 — forked from amboutwe/yoast_seo_breadcrumb_add_woo_shop.php
Multiple examples of how to customize the Yoast SEO breadcrumbs
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/*
* Add shop link to the Yoast SEO breadcrumbs for a WooCommerce shop page.
* Credit: https://wordpress.stackexchange.com/users/8495/rjb
* Last Tested: Apr 20 2017 using Yoast SEO 4.6 on WordPress 4.7.3
*/
add_filter( 'wpseo_breadcrumb_links', 'wpseo_breadcrumb_add_woo_shop_link' );
@apsolut
apsolut / remove-woocommerce-submenu-items
Created October 22, 2020 12:19 — forked from WillBrubaker/remove-woocommerce-submenu-items
Remove WooCommerce submenu items for Shop Managers
<?php
/*
Don't copy the opening php tag
*/
/*
Removes submenu items from WooCommerce menu for 'Shop Managers'
available submenu slugs are:
wc-addons - the Add-ons submenu
wc-status - the System Status submenu