awesome9/json

WordPress json manager.

1.0.2 2021-07-09 04:25 UTC

This package is auto-updated.

Last update: 2024-05-10 08:34:40 UTC


README

Awesome9 Latest Stable Version PHP from Packagist Total Downloads License

68747470733a2f2f696d672e69636f6e73382e636f6d2f6e6f6c616e2f3235362f6a736f6e2e706e67

📃 About JSON

This package provides ease of managing data localization within WordPress.

💾 Installation

composer require awesome9/json

🕹 Usage

First, you need to spin out configuration for your json.

Awesome9\JSON\JSON::get()
	->set_object_name( 'awesome9' );  // Default object name to be output.

Now, let's add and remove some data to be output in admin.

Awesome9\JSON\JSON::get()
	->add( 'company', 'great' )
	->add( 'remove', 'me' )
	->add( 'array', array(
		'a' => 'test',
		'b' => 'test',
	) );

Awesome9\JSON\JSON::get()
	->remove( 'remove' )

And you can use it in your JavaScript files as

console.log( awesome9.company );
console.log( awesome9.array.a );

Available JSON methods

JSON class methods.

Method Description Returns
add( (string) $key, (mixed) $value, (string) $object_name ) Add the variable $this
remove( (string) $var_name, (string) $object_name ) ) Removes the variable $this
clear_all() Clears all data $this
output() Outputs the JSON data

Helper functions

You can use the procedural approach as well:

Awesome9\JSON\add( $key, $value, $object_name = false );

Awesome9\JSON\remove( $key, $object_name = false );

All the parameters remains the same as for the JSON class.

📖 Changelog

See the changelog file