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 / criticalcss-bookmarklet-devtool-snippet.js
Created December 30, 2020 14:52 — forked from PaulKinlan/criticalcss-bookmarklet-devtool-snippet.js
CriticalCSS Bookmarklet and Devtool Snippet.js
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
@apsolut
apsolut / acf-php-to-json.php
Created December 18, 2020 02:49 — forked from ollietreend/acf-php-to-json.php
Convert Advanced Custom Fields Pro configuration from PHP to JSON.
<?php
/**
* Plugin Name: Convert ACF PHP to JSON
* Description: Convert Advanced Custom Fields Pro configuration from PHP to JSON.
*/
namespace ConvertAcfPhpToJson;
/**
* Add submenu item under 'Custom Fields'
@apsolut
apsolut / woocommerce-optimize-scripts.php
Created December 8, 2020 17:10 — forked from DevinWalker/woocommerce-optimize-scripts.php
Only load WooCommerce scripts on shop pages and checkout + cart
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
@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
@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 / 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 / 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 / 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 / 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 / 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/
*/