This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$post_ids = [3011, 2883, 2930, 2912, 2904, 2801, 2640, 2515, 2480, 1505, 1118, 1011, 1098]; | |
function convertRecipeData($post_id) { | |
if($post_id === null) return; | |
echo "============ START POST ID: " . $post_id . " =============\n"; | |
echo "Getting post...\n"; | |
$post = get_post($post_id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$post = get_post(2930); | |
$blocks = parse_blocks( $post->post_content ); | |
foreach ( $blocks as $block ) { | |
if( 'wpzoom-recipe-card/block-recipe-card' === $block['blockName']) { | |
$recipe = [ | |
'title' => $block['attrs']['recipeTitle'], | |
'summary' => array_key_exists('jsonSummary', $block['attrs']) ? $block['attrs']['jsonSummary']: null, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX"></script> | |
<script> | |
window.dataLayer = window.dataLayer || []; | |
function gtag(){dataLayer.push(arguments);} | |
gtag('js', new Date()); | |
gtag('config', 'UA-XXXXXXXX'); | |
</script> | |
<script> | |
function redirect(url) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+[] evaluates to the number zero, because unary-plus tries to convert any value to a number, so that leaves | |
++[[]][0]+[0] | |
[[]][0] is an expression accessing the first element in the array, which is a reference to the inner array. This is shorthand for x = [[]]; x[0];, if it helps you see it better. | |
++[[]][0] then evaluates to a pre-increment of the first element in the array, which returns the value after the element is incremented. Because an array is not numeric, it first needs to coerce it to a number. We saw before that an empty array coerces to 0, so incrementing 0 is 1. If we had a reference to [[]], we’d see that it becomes [1] after the increment operation. (i.e. x = [[]]; ++x[0] // returns 1, and x is now [1]) | |
So, this whole expression boils down to 1 + [0]. Since a number and an array can’t normally be added together, javascript converts both values to strings and concatenates them. | |