Skip to content

Instantly share code, notes, and snippets.

View monecchi's full-sized avatar

Adriano Monecchi monecchi

View GitHub Profile
@andxbes
andxbes / function_v2.php
Last active July 25, 2019 08:56
cf-7 append additional information to mail
<?php
//see https://yadi.sk/i/M5hhJKkU3MkRdN
add_filter("wpcf7_mail_components", function($components, $curent_cf, $sender ){
date_default_timezone_set('America/Sao_Paulo');
$data = date("Y-m-d H:i:s");
$components['body'] = str_replace("[protocol]", $data , $components['body'] );
@vielhuber
vielhuber / functions.php
Last active September 30, 2021 14:59
contact form 7: hook into send mail #php #wordpress
<?php
add_action('wpcf7_before_send_mail', function($cf7)
{
$wpcf = \WPCF7_ContactForm::get_current();
if( strpos($wpcf->title(),'Newsletter') === false )
{
return $wpcf;
}
$email = null;
$first_name = null;
@phillcoxon
phillcoxon / functions.php
Created August 2, 2017 05:29 — forked from TimBHowe/functions.php
WooCommerce - Add custom post_meta data to the order REST API response.
<?php
/**
* Hook into order API response to add custom field data.
*
* @param $order_data array
* @param $order WC_Order
* @param $fields array
* @param $server array
*
@Tusko
Tusko / jquery.ajax.js
Last active November 12, 2021 02:54
$.ajax Promise
/*
* ajax Defaults (optional):
$.ajaxSetup({
type : 'POST',
dataType : 'json',
cache : true,
global : true,
data : {},
contentType : 'application/json',
beforeSend : function (xhr) {
@beardedtim
beardedtim / research2.md
Last active February 22, 2018 23:12
Stripe Multiple Card Research
@amboutwe
amboutwe / yoast_seo_canonical_change_woocom_shop.php
Last active March 6, 2025 17:20
Code snippets for the Yoast SEO canonical output
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Change the canonical link for the shop page
* Credit: Scott Weiss of somethumb.com
* Yoast Doc: https://developer.yoast.com/features/seo-tags/canonical-urls/api/
* Last Tested: Jan 25 2017 using Yoast SEO 6.0 on WordPress 4.9.1
*/
add_filter( 'wpseo_canonical', 'yoast_seo_canonical_change_woocom_shop', 10, 1 );
@thewheat
thewheat / js_intercom.js
Created June 5, 2017 15:23
Sample Drupal 8 installation for Intercom. This is a very rough way of how to install Intercom in Drupal (as I'm not too familiar with Drupal in general). Requires an existing theme in Drupal so replace "themename" in the following files with the actual theme being used
// create this file js/intercom.js
(function ($, Drupal, drupalSettings) {
'use strict';
Drupal.behaviors.attach_intercom = {
attach: function (context, settings) {
window.intercomSettings = drupalSettings.intercom;
// log out of Intercom when logout button clicked
@amboutwe
amboutwe / yoast_seo_opengraph_change_image_size.php
Last active October 28, 2024 06:15
Code snippet to change or remove OpenGraph output in Yoast SEO. There are multiple snippets in this code.
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Change size for Yoast SEO OpenGraph image for all content
* Credit: Yoast Development team
* Last Tested: May 19 2020 using Yoast SEO 14.1 on WordPress 5.4.1
* Accepts WordPress reserved image size names: 'thumb', 'thumbnail', 'medium', 'large', 'post-thumbnail'
* Accepts custom image size names: https://developer.wordpress.org/reference/functions/add_image_size/
*/
@amboutwe
amboutwe / yoast_seo_meta_remove_dates.php
Last active October 5, 2020 08:39
Remove Date Meta Tags Output by Yoast SEO
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Remove Date Meta Tags Output by Yoast SEO
* Credit: Yoast development team
* Last Tested: Apr 09 2019 using Yoast SEO 10.1.3 on WordPress 5.1.1
* For Yoast SEO 14.0 or newer, please see https://yoast.com/help/date-appears-search-results/#h-managing-dates
*/
add_action('wpseo_dc_'.'DC.date.issued', '__return_false'); // Premium versions 5.2 or older
@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() ) {
?>