\WL_View

The WL_View class provides access to remote JSON-LD resources.

Summary

Methods
Properties
Constants
__construct()
filter_page_title()
load()
get_property()
expand()
get_property_html()
get_first_property_html()
get_first_property()
echo_property()
get_property_localized()
get_first_property_localized()
get_first_property_html_localized()
localize_expression()
$base_uri
$suffix
$title
$language
$graph
$url
$json_path
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$base_uri

$base_uri : 

Type

$suffix

$suffix : 

Type

$title

$title : 

Type

$language

$language : 

Type

$graph

$graph : 

Type

$url

$url : 

Type

$json_path

$json_path : 

Type

Methods

__construct()

__construct(string  $base_uri = null, string  $suffix = '.json', string  $title = 'rdfs:label', string  $language = 'en') 

Create an instance of WL_View.

Parameters

string $base_uri

The base URI for resources, default the WordLift dataset.

string $suffix

The suffix to append to URI in order to load the JSON-LD file, default .json.

string $title

The predicate used to set the title of the page, default rdfs:label.

string $language

The language for values, default en.

filter_page_title()

filter_page_title(string  $title, string  $sep) : string

Set the page title using the provided title.

Parameters

string $title

The existing title.

string $sep

The title separator.

Returns

string —

The new title.

load()

load(string  $path = null) 

Load the JSON-LD at the specified path (the path is appended to the *base_uri*). If the path is empty or null it is loaded from the query variables (via WordPress).

Parameters

string $path

The entity path.

get_property()

get_property(string  $name, integer  $index = NULL) : string|array

Get the property with the specified name. The value at the specified index will be returned.

Parameters

string $name

The property name.

integer $index

The value index (default NULL, returns an array of properties).

Returns

string|array —

The property value.

expand()

expand(  $expr) 

Parameters

$expr

get_property_html()

get_property_html(  $name,   $index) 

Parameters

$name
$index

get_first_property_html()

get_first_property_html(string  $name) : string

Gets the first property with the provided name.

Parameters

string $name

The predicate name.

Returns

string —

The value.

get_first_property()

get_first_property(string  $name) : string

Gets the first property with the provided name and returns it HTML escaped.

Parameters

string $name

The predicate name.

Returns

string —

The value.

echo_property()

echo_property(  $name,   $index) 

Parameters

$name
$index

get_property_localized()

get_property_localized(  $name) : string

Parameters

$name

Returns

string

get_first_property_localized()

get_first_property_localized(  $name) 

Parameters

$name

get_first_property_html_localized()

get_first_property_html_localized(  $name) : string

Parameters

$name

Returns

string

localize_expression()

localize_expression(string  $name) : string

Localizes the expression using the language set when creating the view instance.

Parameters

string $name

The expression to localize.

Returns

string —

The localized expression.