Source: A Plug-in by Igor Escobar on Github.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Regex para validação de string no formato CNPJ | |
export const regexCNPJ = /^\d{2}.\d{3}.\d{3}\/\d{4}-\d{2}$/ | |
// Método de validação | |
// Referência: https://pt.wikipedia.org/wiki/Cadastro_Nacional_da_Pessoa_Jur%C3%ADdica | |
export function validCNPJ(value: string | number | number[] = '') { | |
if (!value) return false | |
// Aceita receber o valor como string, número ou array com todos os dígitos | |
const isString = typeof value === 'string' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Change available package rates depending on cart total | |
function shipping_method_on_cart_total( $rates, $package ) { | |
$cart_total = WC()->cart->total; | |
$condition_price = 1000.00; | |
if( $cart_total > $condition_price ) { | |
unset( $rates['free_shipping'] ); // Remove free shipping | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var accounts = [ | |
{ name: 'James Brown', msgCount: 123 }, | |
{ name: 'Stevie Wonder', msgCount: 22 }, | |
{ name: 'Sly Stone', msgCount: 16 }, | |
{ name: 'Otis Redding', msgCount: 300 } // Otis has the most messages | |
]; | |
// get sum of msgCount prop across all objects in array | |
var msgTotal = accounts.reduce(function(prev, cur) { | |
return prev + cur.msgCount; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Export Data to CSV file | |
* Could be used in WordPress plugin or theme | |
*/ | |
// A sample link to Download CSV, could be placed somewhere in plugin settings page | |
?> | |
<a href="<?php echo admin_url( 'admin.php?page=myplugin-settings-page' ) ?>&action=download_csv&_wpnonce=<?php echo wp_create_nonce( 'download_csv' )?>" class="page-title-action"><?php _e('Export to CSV','my-plugin-slug');?></a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PARAMS=('-m 6 -q 70 -mt -af -progress') | |
if [ $# -ne 0 ]; then | |
PARAMS=$@; | |
fi | |
cd $(pwd) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @package Food_example_plugin | |
* @version 1.0 | |
*/ | |
/* | |
Plugin Name: Food example plugin | |
Plugin URI: http://wordpress.org/extend/plugins/# | |
Description: This is an example plugin for WPMU DEV readers | |
Author: Carlo Daniele |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
##Device = Desktops | |
##Screen = 1281px to higher resolution desktops | |
*/ | |
@media (min-width: 1281px) { | |
/* CSS */ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'woocommerce_checkout_fields' , 'virtual_products_less_fields' ); | |
/** | |
* WooCommerce Remove Address Fields from checkout based on presence of virtual products in cart | |
* @link https://www.skyverge.com/blog/checking-woocommerce-cart-contains-product-category/ | |
* @link https://docs.woothemes.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/ | |
* @link https://businessbloomer.com/woocommerce-hide-checkout-billing-fields-if-virtual-product-cart/ | |
*/ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wpr_snap($atts, $content = null) { | |
extract(shortcode_atts(array( | |
"snap" => 'http://s.wordpress.com/mshots/v1/', | |
"url" => 'http://www.sagive.co.il', | |
"alt" => 'My image', | |
"w" => '400', // width | |
"h" => '300' // height | |
), $atts)); | |
$img = '<img src="' . $snap . '' . urlencode($url) . '?w=' . $w . '&h=' . $h . '" alt="' . $alt . '"/>'; |