Skip to content

Instantly share code, notes, and snippets.

Roberto Vaccaro robertito13

Block or report user

Report or block robertito13

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@robertito13
robertito13 / FaviconTest.php
Created Dec 2, 2018
Idea de tests para un Theme de WordPress
View FaviconTest.php
<?php
use PHPUnit\Framework\TestCase;
final class FaviconTest extends TestCase {
public function testFaviconIncluded() {
$icons = array();
$qp = html5qp( SITE_URL );
$qp->find('link[rel="icon"]')->each( function( $i, $node ) use ( &$icons ) {
$icons[] = parse_url( $node->getAttribute( 'href' ), PHP_URL_PATH );
View rss.js
document.addEventListener( 'DOMContentLoaded', function() {
const websiteUrl = 'http://www.anred.org/?feed=rss2';
const entityPattern = /\[(&(?:\#(?:(?<dec>[0-9]+)|[Xx](?<hex>[0-9A-Fa-f]+))|(?<named>[A-Za-z0-9]+));)\]/
const feeds = [
'http://www.anred.org/?feed=rss2'
];
feeds.forEach( function( websiteUrl ) {
fetch( websiteUrl ).then( ( res ) => {
@robertito13
robertito13 / WP_Customize_Editor.php
Last active Aug 9, 2018
Implementación del editor de texto como control para el Customizer de Wordpress
View WP_Customize_Editor.php
<?php
class WP_Customize_Editor extends WP_Customize_Control {
public $type = 'editor';
public function render_content() { ?>
<label>
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
<input id="<?php echo $this->id; ?>-link" type="hidden" class="wp-editor-area" <?php $this->link(); ?> value="<?php echo esc_textarea( $this->value() ); ?>">
<?php
@robertito13
robertito13 / WP_Facebook_Video.php
Created Jul 6, 2018
Videos de Facebook con ancho automático
View WP_Facebook_Video.php
<?php
function auto_width_facebook_video( $result, $url, $args, $post_id ) {
return preg_replace('/data-width="(\d+)"/', 'data-width="auto"', $result);
}
add_filter('embed_oembed_html', 'auto_width_facebook_video', 11, 4);
@robertito13
robertito13 / WP_Clipboard.php
Created Jul 5, 2018
Borrar etiquetas HTML del texto pegado en el editor
View WP_Clipboard.php
<?php
function wp_clean_on_paste( $in ) {
$in['paste_preprocess'] = "function( plugin, args ) {
var whitelist = 'a,p,span,b,strong,i,em,h3,h4,h5,h6,ul,li,ol';
var stripped = jQuery('<div>' + args.content + '</div>');
var els = stripped.find('*').not(whitelist);
for (var i = els.length - 1; i >= 0; i--) {
var e = els[i];
View WP_KeepAlive.php
<?php
if ( !defined( 'ABSPATH' ) ) exit;
function wp_keep_alive($headers, $wp) {
foreach ($headers as $key => $value) {
if ('connection' === strtolower($key)) {
unset($headers[$key]);
}
}
@robertito13
robertito13 / WP_Deduplicator.php
Last active Apr 20, 2018
Evitar los post duplicados al utilizar múltiples loops en WordPress
View WP_Deduplicator.php
<?php
class WP_Deduplicator {
private static $published = array();
public static function add( $post = null ) {
$post = get_post( $post );
if ( !in_array( $post->ID, self::$published ) )
array_push( self::$published, $post->ID );
}
You can’t perform that action at this time.