- A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
- lengths are in any unit (ex: pixels)
- code snippets are in JavaScript
angleRad = angleDeg * Math.PI / 180;
litecanvas() | |
function init () { | |
loadScript('https://unpkg.com/@litecanvas/plugin-more-shapes/dist/dist.js', (res) => { | |
if (res) plugin(pluginMoreShapes) | |
}) | |
size = 100 | |
x = WIDTH/2 - size/2 | |
y = HEIGHT/2 - size/2 |
litecanvas(); | |
const max = 3 | |
const dist = 360 / max | |
function init () { | |
x = CENTERX | |
y = CENTERY | |
a = 0 | |
} |
<?php | |
/* | |
english: put the below code in your functions.php | |
português: coloque o código abaixo no seu functions.php ou siga este guia: https://bit.ly/2Nn0SvD | |
*/ | |
add_filter( 'wc_force_auth_message', function ( $message ) { | |
return 'your new message/sua nova mensagem'; | |
} ); |
const $ = (selector, root = document) => root.querySelector(selector); | |
const $$ = (selector, root = document) => root.querySelectorAll(selector); | |
const on = (el, evt, cb, opts) => el.addEventListener(evt, cb, opts); | |
const once = (el, evt, cb) => el.addEventListener(evt, cb, { once: true }); | |
const off = (el, evt, cb) => el.removeEventListener(evt, cb); |
<?php | |
/** | |
* @param bool $is_valid | |
* @param \WC_Coupon $coupon Coupon data. | |
* @return bool | |
*/ | |
add_filter( 'woocommerce_coupon_is_valid', function ( $is_valid, $coupon ) { | |
if ( ! $is_valid ) return false; |
<?php | |
function is_cnpj ( $value ) { | |
// extrai somente os números | |
$cnpj = \preg_replace( '/[^0-9]/', '', (string) $value ); | |
// valida o tamanho | |
if ( strlen( $cnpj ) !== 14 ) return false; | |
// verifica se todos os digitos são iguais | |
if ( preg_match( '/(\d)\1{13}/', $cnpj ) ) return false; | |
// valida primeiro dígito verificador |
<?php | |
/** | |
* Model to manipulate posts in WordPress | |
* @abstract | |
*/ | |
abstract class Post_Model { | |
/** | |
* @var \WP_Post $post | |
*/ |
<?php | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; // Exit if accessed directly. | |
} | |
// Hooks | |
add_action( 'plugins_loaded', 'yourprefix_include_shipping_method' ); | |
add_action( 'woocommerce_shipping_methods', 'yourprefix_register_shipping_method' ); |