Skip to content

Instantly share code, notes, and snippets.

<link rel="preload" href="/fonts/fuente.woff2" as="font" type="font/woff2" crossorigin>
<link rel="dns-prefetch" href="https://www.google-analytics.com/" />
<link rel="preconnect" href="https://www.google-analytics.com/" />
@goiblas
goiblas / plugin.php
Last active August 4, 2019 09:33
Registrar Bloque y encolar script (WordPress)
<?php
function block_restrict_content_register_block() {
wp_register_script(
'block_restrict_content',
plugins_url( 'build/index.js', __FILE__ ),
array( 'wp-blocks', 'wp-element', 'wp-editor', 'wp-components' ),
'1.0.0'
);
@goiblas
goiblas / add-block-attributes.php
Last active August 4, 2019 09:33
Add Attributes to block (WordPress)
<?php
global $wp_roles;
$all_roles = array_values($wp_roles->get_names());
register_block_type( 'block-restrict-content/block-restrict-content', array(
'editor_script' => 'block_restrict_content',
'attributes' => [
'rolesSelected' => [
'type' => 'array',
@goiblas
goiblas / simple-block.js
Created August 4, 2019 08:50
Structure block (WordPress)
const { registerBlockType } = wp.blocks;
registerBlockType( 'block-restrict-content/block-restrict-content', {
title: 'Restrict Content',
icon: 'lock',
category: 'layout',
edit: ( ) => {
return (
<div>Hola Editor!</div>
)
@goiblas
goiblas / block-restrict-content.js
Created August 4, 2019 08:52
Block restrict content
const { registerBlockType } = wp.blocks;
const { Fragment } = wp.element;
const { InspectorControls } = wp.editor;
const { InnerBlocks } = wp.editor;
const { PanelBody, SelectControl } = wp.components;
registerBlockType( 'block-restrict-content/block-restrict-content', {
title: 'Restrict Content',
icon: 'lock',
@goiblas
goiblas / plugin-restrict-content-block.php
Created August 4, 2019 08:54
Plugin PHP restrict content block
<?php
/**
* @author Jesús Olazagoitia (@goiblas)
* @license GPL2+
*
* @wordpress-plugin
* Plugin Name: Block Restrict Content
* Version: 1.0.0
* Author: Jesús Olazagoitia
* Author URI: https://goiblas.com
@goiblas
goiblas / type-rhythm.css
Last active August 14, 2019 22:16
Type scale css
:root {
--base: 18px;
--rhythm: 32px;
--scale-factor: .48;
}
body, h1, h2, h3, h4, h5, h6 {
font-size: calc( var(--base) + (var(--base) * var(--scale-factor) * var(--font-increase, 0)));
line-height: calc(var(--rhythm) + (var(--rhythm) * var(--rhythm-increase, 0)));
}
:root {
--base: 18px;
--scale-factor: .48;
}
body, h1, h2, h3, h4, h5, h6 {
font-size: calc( var(--base) + (var(--base) * var(--scale-factor) * var(--font-increase, 0)));
}
h1 {
:root {
--base: 16px;
--scale-factor: .28;
--rhythm: 24px;
}
@media(min-width: 768px) {
:root {
--scale-factor: .48;
}
@goiblas
goiblas / payment.php
Created September 9, 2019 06:46
Reto Refactorización WRP 34
<?php
class Payment {
// ... mas codigo
function getCantidades()
{
if ($this->isDead)
return $this->deadAmount();
if ($this->isSeparated)
return $this->separatedAmount();