Skip to content

Instantly share code, notes, and snippets.

View qant's full-sized avatar
💫
Permanent study state

Anton qant

💫
Permanent study state
  • lusa realty, lusa legal, banisio
  • Испания
  • X @antseme
View GitHub Profile
@qant
qant / taxonomy-breadcrumbs.php
Created January 26, 2018 17:50
WordPress custom taxonomy breadcrumbs based on deepest term.
<?php
if( !function_exists( 'inspiry_get_breadcrumbs_items' ) ) :
/**
* Returns a array of breadcrumbs items
*
* @param $post_id int Post id
* @param $breadcrumbs_taxonomy string Taxonomy name
* @return mixed|void
*/
function inspiry_get_breadcrumbs_items( $post_id, $breadcrumbs_taxonomy ) {
@qant
qant / fetchExamples.js
Created January 7, 2020 08:33 — forked from Remzi1993/fetchExamples.js
Examples of using native fetch
// Config / constants
const baseUrl = 'http://localhost:4000' || 'example.herokuapp.com' // or use an environment variable like this: process.env.URL || 'http://localhost:4000'
const JWT = 'Whatever-token'
/*
* Examples of using native fetch
* REST API - CRUD convention (Create/POST, Read/GET, Update/modify/PUT/PATCH, Delete/DELETE)
*
**/
@qant
qant / vanilla-js-cheatsheet.md
Created May 16, 2020 09:09 — forked from thegitfather/vanilla-js-cheatsheet.md
Vanilla JavaScript Quick Reference / Cheatsheet
@qant
qant / docker.md
Created March 5, 2021 11:21 — forked from JacobFierro/docker.md
Docker Cheatsheet

Docker Cheatsheet

Docker info:

docker info

Containers

List Images:

@qant
qant / google_translate.html
Created April 1, 2021 09:53 — forked from carolineschnapp/google_translate.html
Google Translate Embed Code
<div id="google_translate_element"></div>
<script>
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'en'
}, 'google_translate_element');
}
</script>
<script src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
@qant
qant / curl_vs_getheaders.php
Created April 16, 2021 10:56 — forked from 3zzy/curl_vs_getheaders.php
cURL vs get_headers() Speed Test
<?php
// Get headers for 100 unique random domains with get_headers() and cURL to determine which is faster.
/*
TL;DR -> cURL is significantly faster.
get_headers (GET) vs cURL:
Execution time : 139.95884609222 seconds
Execution time : 65.998840093613 seconds
@qant
qant / woo-events.js
Created May 29, 2021 08:51 — forked from bagerathan/woo-events.js
Woocommerce Javascript events #woocommerce
//Woocommerce Checkout JS events
$( document.body ).trigger( 'init_checkout' );
$( document.body ).trigger( 'payment_method_selected' );
$( document.body ).trigger( 'update_checkout' );
$( document.body ).trigger( 'updated_checkout' );
$( document.body ).trigger( 'checkout_error' );
//Woocommerce cart page JS events
$( document.body ).trigger( 'wc_cart_emptied' );
$( document.body ).trigger( 'update_checkout' );
@qant
qant / lenura_empty_cart_before_add.php
Created May 29, 2021 11:48 — forked from viniciusrtf/lenura_empty_cart_before_add.php
WooCommerce Hook: Empty cart before adding a new product to cart WITHOUT throwing woocommerce_cart_is_empty
<?php
/**
* Hook: Empty cart before adding a new product to cart WITHOUT throwing woocommerce_cart_is_empty
*/
add_action ('woocommerce_add_to_cart', 'lenura_empty_cart_before_add', 0);
function lenura_empty_cart_before_add() {
global $woocommerce;
// Get 'product_id' and 'quantity' for the current woocommerce_add_to_cart operation
@qant
qant / woocommerce-popular-products.php
Created March 24, 2022 08:23 — forked from aslamdoctor/woocommerce-popular-products.php
Woocommerce : Get popular products using wp_query
@qant
qant / filter.php
Created May 7, 2022 07:13 — forked from cfxd/filter.php
Efficient Responsive Images in WordPress. See https://cfxdesign.com/efficient-responsive-images-in-wordpress
<?php
/*
* THE FILTER
*
*/
function custom_responsive_image_sizes($sizes, $img_name, $attachment_id) {
$sizes = wp_get_attachment_image_sizes($attachment_id, 'original');
$meta = wp_get_attachment_metadata($attachment_id);
$width = $meta['width'];