Skip to content

Instantly share code, notes, and snippets.

View dariodev's full-sized avatar

Dario Devcic dariodev

  • Zagreb
View GitHub Profile
@dariodev
dariodev / gist:a9b969605fe8b65aa790b2a0759d8b26
Created January 4, 2017 20:18
WooCommerce - Show number of items in cart and total
<a class="cart-contents" href="<?php echo wc_get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf ( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?> - <?php echo WC()->cart->get_cart_total(); ?></a>
@dariodev
dariodev / calc-read-time.php
Created January 18, 2017 11:05 — forked from norcross/calc-read-time.php
calculate and display an estimated reading time
<?php
/**
* handle the calculation
* @param integer $seconds [description]
* @return [type] [description]
*/
function rkv_calc_read_time( $seconds = 0 ) {
// calc the minutes
@dariodev
dariodev / style.css
Last active May 31, 2019 02:40
Styling WP Subscribe widget for Themelia theme
/**
* Style for WP Subscribe
* to match Themelia theme
*
* (NOTE: remove <br> and <span> tags from widget -> Labels -> Title)
*/
.widget #wp-subscribe {
background-color: rgba(34, 34, 42, .055);
padding: 1.5rem;
@dariodev
dariodev / wp_mail.md
Created August 4, 2017 22:17 — forked from johnbillion/wp_mail.md
WordPress Emails

WordPress Emails

This document lists all the situations where WordPress sends an email, along with how to filter or disable each email.

This is accurate as of WordPress 4.8, and includes some upcoming changes in WordPress 4.9.

There are a few TODOs left. Please bear with me.

@dariodev
dariodev / one-theme-two-textdomains.php
Created August 6, 2017 16:04 — forked from justintadlock/one-theme-two-textdomains.php
How one theme can have two textdomains and still work with translation systems.
<?php
/**
* The purpose of this file is to show how a theme can have multiple textdomains
* and still work with a single translation file. Translation tools like the
* one used on WordPress.org and Poedit are going to simply scan the project for
* text strings, regardless of the textdomain (and for good reasons that are
* not relevant here).
*
* The code below works with that system. It assumes that we have a single MO
* file based on the theme's textdomain. So, how can two textdomains work? It
@dariodev
dariodev / styles.css
Created August 31, 2017 16: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/
*/
@dariodev
dariodev / acf-pagination.php
Created September 7, 2017 21:41 — forked from kisabelle/acf-pagination.php
ACF Repeater Field Pagination
<?php
/*
* Paginate Advanced Custom Field repeater
*/
if( get_query_var('page') ) {
$page = get_query_var( 'page' );
} else {
$page = 1;
}
@dariodev
dariodev / gist:31717158d365c078cc0017a8e9b996e4
Created July 3, 2018 21:51 — forked from digitaljhelms/gist:4287848
Git/GitHub branching standards & conventions

Branching

Quick Legend

Description, Instructions, Notes
Instance Branch
@dariodev
dariodev / primary-category.php
Last active February 15, 2019 18:28
WordPress get the primary category for a post (Yoast’s “Primary” Category )
<?php
// Show Yoast’s “Primary” Category. Fallback to first category.
$category = get_the_category();
$usecatlink = true;
// If post has a category assigned.
if ( $category ) {
$category_display = '';
$category_link = '';
if ( class_exists( 'WPSEO_Primary_Term' ) ) {
// Show the post's 'Primary' category, if this Yoast feature is available, & one is set.
function parseVideo (url) {
// - Supported YouTube URL formats:
// - http://www.youtube.com/watch?v=My2FRPA3Gf8
// - http://youtu.be/My2FRPA3Gf8
// - https://youtube.googleapis.com/v/My2FRPA3Gf8
// - Supported Vimeo URL formats:
// - http://vimeo.com/25451551
// - http://player.vimeo.com/video/25451551
// - Also supports relative URLs:
// - //player.vimeo.com/video/25451551