Skip to content

Instantly share code, notes, and snippets.

View dashdanilo's full-sized avatar
🎯
Focusing

Danilo Rodrigues dashdanilo

🎯
Focusing
View GitHub Profile
@dashdanilo
dashdanilo / functions.php
Created April 10, 2022 00:38 — forked from alexander-young/functions.php
Defer Javascript in WordPress
function defer_parsing_of_js($url)
{
if (is_admin()) return $url; //don't break WP Admin
if (false === strpos($url, '.js')) return $url;
if (strpos($url, 'jquery.js')) return $url;
return str_replace(' src', ' defer src', $url);
}
add_filter('script_loader_tag', 'defer_parsing_of_js', 10);

Modules for Creative Coding

This workshop encourages students to make use of npm modules to build complex and interesting artworks.

If you find a module you want to use, like riso-colors, you can install it from your project folder like so:

npm install riso-colors
@dashdanilo
dashdanilo / yup.locale.pt-br.js
Created October 8, 2019 19:59 — forked from max10rogerio/yup.locale.pt-br.js
Translation of the main messages from the Yup library into the Pt-Br language.
// For more infos, see: https://github.com/jquense/yup/blob/master/src/locale.js
import { setLocale } from 'yup'
const translation = {
mixed: {
default: '${path} é inválido',
required: '${path} é um campo obrigatório',
oneOf: '${path} deve ser um dos seguintes valores: ${values}',
notOneOf: '${path} não pode ser um dos seguintes valores: ${values}',
},
<?php if(get_field('slides')): $i = 0; while(has_sub_field('slides')): $i++; if ($i != 1): ?>
<!-- Do Stuff Here -->
<?php endif; endwhile; endif; ?>
<!-- http://support.advancedcustomfields.com/forums/topic/repeater-skip-first-row/ -->
@dashdanilo
dashdanilo / css-empty.md
Created November 23, 2016 20:24 — forked from felipefialho/css-empty.md
[CSS Trick] Hide dynamic element that break the layout when it is empty.

Hide dynamic element that break the layout when it is empty.

&:empty
  display none

!important, it can't has space on HTML

✌️

@dashdanilo
dashdanilo / facebook-messenger-bot.php
Created July 7, 2016 06:05 — forked from remmel/facebook-messenger-bot.php
Basic example of a Facebook Messenger Bot
<?php
// parameters
$hubVerifyToken = 'TOKEN123456abcd';
$accessToken = "xxx";
// check token at setup
if ($_REQUEST['hub_verify_token'] === $hubVerifyToken) {
echo $_REQUEST['hub_challenge'];
exit;
}
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
<?php if ( get_field( 'slides' ) ) : // repeater field ?>
<ul class="slider">
<?php while ( the_repeater_field( 'slides' ) ) :
$image = get_sub_field( 'slide' ); // sub-field image ID
$slide = wp_get_attachment_image_src( $image, 'slides' );
$alt = get_post_meta( $image, '_wp_attachment_image_alt', true );
?>
<li><img src="<?php echo $slide[0]; ?>" alt="<?php echo $alt; ?>"></li>
<?php endwhile; ?>
<?php
// WP_Query arguments
$args = array (
'post_type' => 'tipodopost',
'category_name' => 'slugdacategoria',
'posts_per_page' => '-1',
);
// The Query
$query = new WP_Query( $args );