Noted November 5, 2015

Interesting this produces a truthy or falsy string

<?php
wp_localize_script( 'pwcc-functions', 'pwccConfig', array(
  'isSingle' => is_single(),
) );

but this is all lovely and boolean.

<?php
wp_localize_script( 'pwcc-functions', 'pwccConfig', array(
  'is' => array(
    'single' => is_single(),
  )
) );

It’s an abuse of the localisation function so I can see why it expects a string.

Coincidently, a related trac ticket was opened a few hours after this post.

By Peter Wilson

Peter has worked on the web for twenty years on everything from table based layouts in the 90s to enterprise grade CMS development. Peter’s a big fan of musical theatre and often encourages his industry colleagues to join him for a show or two in New York or in the West End.

3 comments

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.