Skip to content

Instantly share code, notes, and snippets.

@blueprintmrk
blueprintmrk / decode_unicode_google_maps_api.php
Created February 25, 2020 23:03 — forked from dertajora/decode_unicode_google_maps_api.php
Decode Encoded Unicode string (field html-instruction) on Google Maps API response
<?php
// Lets say , we want to send a direction request with guidance to Google Maps API using link below.
// https://maps.googleapis.com/maps/api/directions/json?origin=-6.190109,%20106.798565&destination=-6.177596,%20106.792611&key=USEYOUR_KEY
// some of request, especially in field html-instruction would return unicode html text like this one ('Head \u003cb\u003ewest\u003c/b\u003e').
// for some reason, I just want to use the text provided there ('Head west').
// after some googling and asking, here is the best code I have (right now)
# example response
//Type A : There are 2 sentence in one single direction response
@blueprintmrk
blueprintmrk / woocommerce-optimize-scripts.php
Created March 18, 2020 18:47 — 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' ) );
@blueprintmrk
blueprintmrk / yoast-homepage
Created March 25, 2020 00:16 — forked from patrickcoombe/yoast-homepage
Yoast Homepage
<script type = 'application/ld+json' class = 'yoast-schema-graph yoast-schema-graph--main'> {
"@context": "https://schema.org",
"@graph": [{
"@type": "Organization",
"@id": "https://yoast.com/#organization",
"name": "Yoast",
"url": "https://yoast.com/",
"sameAs": ["https://www.facebook.com/yoast", "https://www.instagram.com/yoast/", "https://www.linkedin.com/company/1414157/", "https://www.youtube.com/yoast", "https://www.pinterest.com/yoast/", "https://en.wikipedia.org/wiki/Yoast", "https://twitter.com/yoast"],
"logo": {
"@type": "ImageObject",
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@blueprintmrk
blueprintmrk / twitter-cards.liquid
Created June 9, 2020 15:40 — forked from chrisjhoughton/twitter-cards.liquid
Twitter Card meta tags for Shopify. Add this as a snippet called "twitter-cards.liquid" in your theme, and then add {% include 'twitter-cards' %} to your theme.liquid file.
{% comment %}
This snippet renders meta data needed to create a Twitter card
for products and articles.
IMPORTANT: change @your_twitter_username with your actual twitter username!
Your cards must be approved by Twitter to be activated
- https://dev.twitter.com/docs/cards/validation/validator
@blueprintmrk
blueprintmrk / twitter-cards.liquid
Created June 9, 2020 15:40 — forked from kitop/twitter-cards.liquid
Twitter Cards Snippet for Shopify Stores
{% comment %}
This is for widgets that share content on Twitter.
Twitter developer info: https://dev.twitter.com/docs/cards
Brought to you by Viralica http://viralica.com
{% endcomment %}
{% if template contains 'product' %}
<meta name="twitter:card" content="product">
<meta name="twitter:title" content="{{ product.title }}" />
<meta name="twitter:description" content="{{ product.description | strip_html | strip_newlines | truncatewords: 160, '' | escape }}" />
@blueprintmrk
blueprintmrk / product-json-ld.liquid
Created September 3, 2020 20:36 — forked from svaustin66/product-json-ld.liquid
Example of Structured Data for Shopify Product
{% assign current_variant = product.selected_or_first_available_variant %}
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Product",
"@id": "{{ shop.url | append: '/products/' | append: product.handle }}",
"url": "{{ shop.url | append: '/products/' | append: product.handle }}",
"name": "{{ product.title }}",
"image": "{{ product.featured_image.src | img_url: 'master' }}",
{% when 'product' %}
{% if collection.url %}
<li>
{{ collection.title | link_to: collection.url }}
</li>
{% endif %}
<li>
<a href="{{ product.url }}" aria-current="page">{{ product.title }}</a>
{% when 'collection' and collection.handle %}
{% if current_tags %}
<li>{{ collection.title | link_to: collection.url }}</li>
<li>
{% capture tag_url %}{{ collection.url }}/{{ current_tags | join: "+"}}{% endcapture %}
<a href="{{ tag_url }}" aria-current="page">{{ current_tags | join: " + "}}</a>
</li>
{% else %}
<li>