Skip to content

Instantly share code, notes, and snippets.

@trepmal
Created April 7, 2014 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trepmal/10050351 to your computer and use it in GitHub Desktop.
Save trepmal/10050351 to your computer and use it in GitHub Desktop.
<?php
// This is probably a bad idea.
class LocalizeTest {
function __construct( $instance ) {
$this->instance = $instance;
add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
}
function wp_enqueue_scripts() {
$instance_identifier = $this->instance;
wp_enqueue_script( 'lorem', plugins_url('lorem.js',__FILE__) );
wp_localize_script( 'lorem', 'lorem = (lorem ? lorem : new Object ); lorem.'.$instance_identifier, array(
'this' => 'that'
) );
}
}
new LocalizeTest( 'one' );
new LocalizeTest( 'two' );
console.log( lorem );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment