Manages a set of info to be printed as a json generally at the endo of the page

author etessore
version 1.0.1
package classes

 Methods

Initializes the current set of infos with default values

__construct() 

Adds an info to the current set

add_info(string $key, string $value) : \RuntimeInfos

Parameters

$key

string

the name of the info

$value

string

the value of the info

Returns

\RuntimeInfos$this for chainability

Callback executed when the admin ajax url is called with self::ajax_action parameter

ajax_callback() 
Static

Retrieves the html markup

get_markup() : string

Returns

stringhtml markup

Hook the print of this infos to Wordpress footer

hook() : \RuntimeInfos

Returns

\RuntimeInfos$this for chainability

Registers and enqueue the js from admin-ajax.php This has to be called after RuntimeInfos::generate_unique_id()

load_assets() 

Sets the default values: postID, theme_url, upload_dir, home_url and ajaxurl

set_standard_infos() 

Sets the type

set_type(int $type) 

Prints the markup

the_markup() 

Format the data set in JSON.

render() 

Overload this if you want a different data structure, i.e. XML

Generates an unique ID for the current data set

generate_unique_id() : string

Returns

stringthe ID

Get the ID for the current post

get_the_ID() 

 Properties

 

the list of infos

$infos : array
 

the way we want the infos

$type : int
 

id of the post these infos refer to

$id : int

 Constants

 

<p>uset this as type to have an external js on an admin-ajax.php url</p>

TYPE_AJAX : int
   

<p>the action parameter for the admin-ajax</p>

ajax_action : string