tp TouchPointWP TouchPointWP_AdminAPI - TenthPres/TouchPoint-WP GitHub Wiki

tp\TouchPointWP\TouchPointWP_AdminAPI

Admin API class.


Constants

Constant Visibility Type Value
API_ENDPOINT_SCRIPTZIP public "scriptzip"

Methods

__construct

Constructor function

public __construct(): mixed

api

Handle API requests

public static api(array $uri): bool
  • This method is static. Parameters:
Parameter Type Description
$uri array The request URI already parsed by parse_url()

Return Value:

False if endpoint is not found. Should print the result.


displayField

Generate HTML for displaying fields.

public displayField(array $data = [], ?\WP_Post $post = null, bool $echo = true): string

Parameters:

Parameter Type Description
$data array Data array.
$post ?\WP_Post Post object.
$echo bool Whether to echo the field HTML or return it.

generatePython

Generate the python scripts to be uploaded to TouchPoint.

public generatePython(bool $toZip, array $filenames = ['*']): string|array

Parameters:

Parameter Type Description
$toZip bool Set true to combine into a Zip file.
$filenames array Indicate which files should be included, based on their repo name.
Add '*' to the array to include all files regardless of name.

Return Value:

If toZip is true, returns the file path of the zip file. If toZip is false, returns an array of filename => content.

Throws:


showError

Display an error when there's something wrong with the TouchPoint connection.

public static showError(string $message, ?mixed $devDetail = null): void
  • This method is static. Parameters:
Parameter Type Description
$message string
$devDetail ?mixed