Skip to content

Instantly share code, notes, and snippets.

View monecchi's full-sized avatar

Adriano Monecchi monecchi

View GitHub Profile
@monecchi
monecchi / wc-customer-orders-number.php
Last active September 18, 2023 13:40
WooCommerce Customer's Orders Total - Sum of all the current month's orders made by a customer
/*********************************************************************************************/
/** Get the total sum (money spent) of orders made by a user with a "complete" status in WooCommerce. This will output the current month's sum of all orders made by the customer. **/
/*********************************************************************************************/
<?php
function current_customer_month_count( $user_id=null ) {
if ( empty($user_id) ){
$user_id = get_current_user_id();
}
<?php
/*
* WordPress Breadcrumbs
* author: Dimox
* version: 2017.21.01
* license: MIT
*/
function dimox_breadcrumbs() {
/* === OPTIONS === */
@monecchi
monecchi / tab-active-url-hash.php
Last active January 19, 2017 03:38 — forked from corsonr/gist:0e0a4dfaacf59fdca314
WooCommerce: activate product tabs from URL
<?php
/**
* wc_direct_link_to_product_tabs
*
* Allows you to create custom URLs to activate product tabs by default, directly from the URL
* ex: http://mysite.com/my-product-name#reviews
*/
function wc_direct_link_to_product_tabs() {
if( is_product() ) {
?>
@monecchi
monecchi / get-users-first-last-name-wordpress.php
Created December 1, 2016 23:28 — forked from kellenmace/get-users-first-last-name-wordpress.php
Get User's First and Last Name in WordPress
<?php
/**
* Get user's first and last name, else just their first name, else their
* display name. Defalts to the current user if $user_id is not provided.
*
* @param mixed $user_id The user ID or object. Default is current user.
* @return string The user's name.
*/
function km_get_users_name( $user_id = null ) {
@monecchi
monecchi / checkout-webservice.css
Last active September 5, 2016 17:46
Cielo WooCommerce - Webservice - Credit Card Icons
/*
* Cielo WooCommerce Webservice - Credit Card brand icons on input background
* by Adriano Monecchi - Twitter: @dico_monecchi
* Download Cielo Credit Card Icons sprite images bellow:
* Cielo Credit Cards: https://cldup.com/UrOOO8uMsm.png
* Cielo Debit Card: https://cldup.com/LrSaBXSM-Z.png
* See Demo: http://pizzariameurancho.co.nf/home/checkout/
*/
/* Cielo Credit Cards */
@monecchi
monecchi / bin-cc.md
Created August 31, 2016 18:33 — forked from erikhenrique/bin-cc.md
Bin de cartões de crédito para validação

Validação para cartão de crédito.

Bin e padrões para validação de cartão de crédito.

Bandeira Começa com Máximo de número Máximo de número cvc
Visa 4 13,16 3
Mastercard 5 16 3
//Register Meta with Rest API
add_action( 'rest_api_init', 'prefix_register_custom_meta' );
function prefix_register_custom_meta() {
register_rest_field(
'post',
'_prefix_url',
array(
'get_callback' => 'prefix_get_custom_meta',
'update_callback' => null,
'schema' => null,
/**
* Retrieve custom meta for use in the REST API
*
* @param array $object Details of current post.
* @param string $field_name Name of field.
* @param WP_REST_Request $request Current request
*
* @return mixed
*/
function prefix_get_custom_meta( $object, $field_name, $request ) {
@monecchi
monecchi / wordpress-seo-keywords-bs.php
Created June 15, 2016 20:26 — forked from robneu/wordpress-seo-keywords-bs.php
WordPress SEO without a plugin is complete crap. Let's break it down one function at a time.
<?php
function basic_wp_seo() {
global $page, $paged, $post;
$default_keywords = 'wordpress, plugins, themes, design, dev, development, security, htaccess, apache, php, sql, html, css, jquery, javascript, tutorials'; // customize
$output = '';
// description
$seo_desc = get_post_meta($post->ID, 'mm_seo_desc', true);
$description = get_bloginfo('description', 'display');
$pagedata = get_post($post->ID);
@monecchi
monecchi / dcWPFunctions.html
Created June 15, 2016 20:24 — forked from dcondrey/dcWPFunctions.html
My collection of custom functions for use with WP. Manipulating post content and titles, article content and titles, seo, cleanup, etc, misc..
<?php
/**
* Limit previous/next post title character length and append a ellipsis if trunicated
*/
$previous_post = get_adjacent_post( false, '', true );
$next_post = get_adjacent_post( false, '', false );
$previous_post_title= get_the_title($previous_post);
$next_post_title = get_the_title($next_post);
$max_length = 75;
$previous_post_length = strlen($previous_post_title);