Skip to content

Instantly share code, notes, and snippets.

View marcosnakamine's full-sized avatar

Marcos Nakamine marcosnakamine

View GitHub Profile
@marcosnakamine
marcosnakamine / functions.php
Last active March 29, 2017 11:18 — forked from WPprodigy/functions.php
WooCommerce - Remove the password strength meter
<?php
add_action( 'wp_print_scripts', 'wc_remove_password_strength', 100 );
function wc_remove_password_strength() {
if ( wp_script_is( 'wc-password-strength-meter', 'enqueued' ) ) {
wp_dequeue_script( 'wc-password-strength-meter' );
}
}
@marcosnakamine
marcosnakamine / index.php
Created February 15, 2017 18:13
PHP - Sending header in cURL
<?php
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, 'http://url.com' );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/xml' ) );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$output = curl_exec( $ch );
curl_close( $ch );
var_dump( $output );
@marcosnakamine
marcosnakamine / class.ys_mail.php
Last active November 18, 2023 06:57
WordPress - Send mail wp_mail with attachment
<?php
class YS_Mail {
public function YS_Mail() {}
public function enviar( $e ) {
$headers = "From: ".$e['from_name']." <".$e['to_mail']."> \n";
$headers .= "Reply-To:".$e['from_name']." <".$e['from_mail']."> \n";
@marcosnakamine
marcosnakamine / functions.php
Last active March 10, 2017 13:18 — forked from jameskoster/functions.php
WooCommerce - Declare support in theme
<?php
add_action( 'after_setup_theme', 'woocommerce_support' );
function woocommerce_support() {
add_theme_support( 'woocommerce' );
}
@marcosnakamine
marcosnakamine / functions.php
Last active March 10, 2017 13:18 — forked from jameskoster/functions.php
WooCommerce - Change number of columns on archives
<?php
add_filter( 'projects_loop_columns', 'jk_projects_columns', 99 );
function jk_projects_columns( $cols ) {
$cols = 3;
return $cols;
}
@marcosnakamine
marcosnakamine / functions.php
Last active March 10, 2017 13:20 — forked from SirDarcanos/functions.php
WooCommerce - Hide shipping rates when free shipping is available
<?php
/**
* Hide shipping rates when free shipping is available.
* Updated to support WooCommerce 2.6 Shipping Zones.
*
* @param array $rates Array of rates found for the package.
* @return array
*/
function my_hide_shipping_when_free_is_available( $rates ) {
$free = array();
@marcosnakamine
marcosnakamine / download.sh
Created February 9, 2017 10:40
Shell - Download with wget authentication
#!/bin/bash
wget --auth-no-challenge --user='user' --password='pass' 'url'
@marcosnakamine
marcosnakamine / functions.php
Last active March 10, 2017 13:20
WooCommerce - Apply automatic discount coupon
<?php
add_action( 'woocommerce_before_cart', 'apply_auto_coupons' );
function apply_auto_coupons() {
if ( WC()->cart->get_cart_contents_count() >= 6 && !in_array( 'COUPON_CODE', WC()->cart->applied_coupons ) ) {
WC()->cart->add_discount( 'COUPON_CODE' );
}
}
@marcosnakamine
marcosnakamine / woocommerce.php
Last active March 10, 2017 13:20
WooCommerce - Get number of items in cart
<?php
echo WC()->cart->get_cart_contents_count();
@marcosnakamine
marcosnakamine / functions.php
Last active March 10, 2017 13:20
WooCommerce - Execute when product status changed
<?php
add_action( 'woocommerce_order_status_changed', 'status_changed' );
function status_changed() {
// code
}