1. Go to this page and download the library: Download varunsridharan/wp-localizer library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
varunsridharan / wp-localizer example snippets
/**
* Create A New Instance
*/
$instance = \Varunsridharan\WordPress\Localizer::instance( array(
'id' => 'myplugin',
'scripts' => array( 'my-plugin-script' ),
'frontend' => true,
'functions' => true,
) );
/**
* Get Existing Instance
*/
$instance_existing = \Varunsridharan\WordPress\Localizer::instance( 'myplugin' );
$instance->add( 'alert_info', array(
'show' => false # It can be Array / String / Bool / Int
) );
$instance->add( 'object2', 'Some Value'/* It can be Array / String / Bool / Int */ );
/**
* Merges With Existing object1 value.
*/
$instance->add( 'alet_info', array(
'title' => 'Some Value',
), true );
// Translation.
$instance->text('alert_title',__('Your Alert Title'));
javascript
var $arg = myplugin_option( 'alert_info' );
if(true === $arg.show){
alert($arg.title);
}
alert(myplugin_txt('alert_title','Default Title Here'));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.