Skip to content

Instantly share code, notes, and snippets.

View marcosnakamine's full-sized avatar

Marcos Nakamine marcosnakamine

View GitHub Profile
@marcosnakamine
marcosnakamine / wc-skeleton-shipping-method-example.php
Created July 24, 2020 14:04 — forked from woogists/wc-skeleton-shipping-method-example.php
[Shipping Method API] WooCommerce skeleton shipping method plugin code example.
<?php
/*
Plugin Name: Your Shipping plugin
Plugin URI: https://woocommerce.com/
Description: Your shipping method plugin
Version: 1.0.0
Author: WooThemes
Author URI: https://woocommerce.com/
*/
@marcosnakamine
marcosnakamine / .htaccess
Created August 13, 2019 15:13
WordPress - Protect uploads folder when not logged
RewriteEngine On
RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]
RewriteRule ^.*/uploads/.*$ http://domain.com/protected.jpg [L,R=301]
namespace: "flex-", //{NEW} String: Prefix string attached to the class of every element generated by the plugin
selector: ".slides > li", //{NEW} Selector: Must match a simple pattern. '{container} > {slide}' -- Ignore pattern at your own peril
animation: "fade", //String: Select your animation type, "fade" or "slide"
easing: "swing", //{NEW} String: Determines the easing method used in jQuery transitions. jQuery easing plugin is supported!
direction: "horizontal", //String: Select the sliding direction, "horizontal" or "vertical"
reverse: false, //{NEW} Boolean: Reverse the animation direction
animationLoop: true, //Boolean: Should the animation loop? If false, directionNav will received "disable" classes at either end
smoothHeight: false, //{NEW} Boolean: Allow height of the slider to animate smoothly in horizontal mode
startAt: 0, //Integer: The slide that the slider should start on. Array nota
@marcosnakamine
marcosnakamine / .htaccess
Created September 25, 2018 14:17
WordPress - Adding Cache-Control Headers in Apache
<filesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|svg|js|css|swf)$">
Header set Cache-Control "max-age=84600, public"
</filesMatch>
@marcosnakamine
marcosnakamine / functions.php
Last active April 9, 2018 20:31
WooCommerce - Remove and add my account tab menu
<?php
// https://rudrastyh.com/woocommerce/my-account-menu.html
/* add CSS
body.woocommerce-account ul li.woocommerce-MyAccount-navigation-link--log-history a:before{
content: "\f1da";
}
*/
/*
* Step 1. Add Link to My Account menu
@marcosnakamine
marcosnakamine / index.php
Created February 5, 2018 16:29
PHP - Get information of brazilian CEP
<?php
$cep = '17013021';
$token = 'API_KEY';
// Recebe o CEP
$curl = curl_init( 'http://www.cepaberto.com/api/v2/ceps.json?cep='.$cep );
// Adiciona o token no cabeçalho
curl_setopt( $curl, CURLOPT_HTTPHEADER, array( 'Authorization: Token token="'.$token.'"' ) );
@marcosnakamine
marcosnakamine / index.php
Created February 5, 2018 13:46
PHP - Get Instawidget images and links
<?php $instagram = simplexml_load_file( 'https://instawidget.net/feed/user/google' ) ?>
<?php foreach ( $instagram->channel->item as $key => $value ): ?>
<a href="<?php echo $value->link ?>">
<img src="<?php echo $value->enclosure['url'] ?>" alt="">
</a>
<?php endforeach ?>
@marcosnakamine
marcosnakamine / function.php
Created January 30, 2018 17:28
WordPress - Change language programmatically via url
<?php
function wpsx_redefine_locale( $locale ) {
$lang = $_GET['lang'];
if( $lang == 'en'){
$locale = 'en_US';
} else {
$locale = 'pt_BR';
}
return $locale;
}
@marcosnakamine
marcosnakamine / script.js
Created October 24, 2017 13:28
jQuery - WP Smush auto click
setInterval(function(){
botao = jQuery('#wp-smush-bulk-wrap-box > div.box-container > div.wp-smush-bulk-wrapper > button');
if( botao.attr('disabled') != 'disabled' ) {
botao.trigger('click');
}
}, 1000);
@marcosnakamine
marcosnakamine / index.php
Created October 17, 2017 13:16
PHP - Get Instagram images with file_get_contents
<?php $instagram = json_decode( file_get_contents( 'https://www.instagram.com/user_name/media/' ) ) ?>
<?php for ( $i=0; $i<4; $i++ ): ?>
<a href="https://www.instagram.com/p/<?php echo $instagram->items[$i]->code ?>" target="_blank"><img src="<?php echo $instagram->items[$i]->images->low_resolution->url ?>" alt=""></a>
<?php endfor ?>