Skip to content

Instantly share code, notes, and snippets.

View RobStino's full-sized avatar
🏄‍♂️

Rob RobStino

🏄‍♂️
View GitHub Profile
@RobStino
RobStino / block.php
Created October 9, 2019 09:57
Advanced Custom Fields & Block Lab PHP template file
<?php
// Variables.
$post_type = 'review';
$post_count = block_value( 'number' );
// WP_Query arguments.
$args = array(
'post_type' => array( $post_type ),
'posts_per_page' => $post_count,
@RobStino
RobStino / simple_amp_html.html
Created January 8, 2019 23:26
Simple AMP HTML
<!doctype html>
<html ⚡>
<head>
<meta charset="utf-8">
<link rel="canonical" href="hello-world.html">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<script async src="https://cdn.ampproject.org/v0.js"></script>

Keybase proof

I hereby claim:

  • I am robstino on github.
  • I am stino (https://keybase.io/stino) on keybase.
  • I have a public key ASAh5TUXhq1GISRohQwKqzC7rEIhatiQaYNkoamKJNB6zQo

To claim this, I am signing this object:

@RobStino
RobStino / Braces
Last active February 28, 2018 03:56
// Not this
if ( condition() )
return true;
// This
if ( condition() ) {
return true;
}
// This is clever
isset( $var ) || $var = some_function();
// But this is readable
if ( ! isset( $var ) ) {
$var = some_function();
}
if ( true === $the_force ) {
$victorious = you_will( $be );
}
// This is one way
global $wpdb;
$post_author = $_POST['author_id'];
$results = $wpdb->get_results(
"SELECT ID, post_title
FROM $wpdb->posts
WHERE post_status = 'publish' AND post_author = $post_author"
// Don't do this
$secondary_email = $_POST[ 'email' ];
update_user_meta( $user_id, 'secondary_email', $secondary_email );
// Do this
$secondary_email = sanitize_email( $_POST[ 'email' ] );
update_user_meta( $user_id, 'secondary_email', $secondary_email );
// Don't do this
$title = $_POST['title'];
update_post_meta( $post->ID, 'title', $title );
// Do this
$title = sanitize_text_field( $_POST['title'] );
update_post_meta( $post->ID, 'title', $title );
// Don't do this
$foo = $_GET[ 'foo' ];
$bar = $_GET[ 'bar' ];
echo '<p id="' . $foo . '">' . $bar . '</p>';
// Do this
echo wp_kses_post(
sprintf(