tp TouchPointWP Report - TenthPres/TouchPoint-WP GitHub Wiki

tp\TouchPointWP\Report

The Report class gets and processes a SQL or Python report from TouchPoint and presents it in the UX.

Constants

SHORTCODE_REPORT

const SHORTCODE_REPORT = \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Report"

POST_TYPE

const POST_TYPE = \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "report"

META_PREFIX

const META_PREFIX = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . "rpt_"

CRON_HOOK

const CRON_HOOK = \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "report_cron_hook"

TYPE_META_KEY

const TYPE_META_KEY = self::META_PREFIX . "type"

NAME_META_KEY

const NAME_META_KEY = self::META_PREFIX . "name"

P1_META_KEY

const P1_META_KEY = self::META_PREFIX . "p1"

DEFAULT_CONTENT

const DEFAULT_CONTENT = ''

Properties

classDefault

public mixed classDefault = "TouchPoint-report"
  • Visibility: public

_isLoaded

public mixed _isLoaded = false
  • Visibility: public

Methods

fromParams

mixed tp\TouchPointWP\Report::fromParams(mixed params)

Get a Report object, based on standard parameters (generally, the parameters used for the shortcode)

  • Visibility: public
  • This method is static.

Arguments

  • params mixed

Returns

  • mixed

load

bool tp\TouchPointWP\module::load()

Loads the module and initializes the other actions.

Returns

  • bool -

init

mixed tp\TouchPointWP\Report::init()

Register stuff

  • Visibility: public
  • This method is static.

Returns

  • mixed

api

bool tp\TouchPointWP\api::api(array uri)

Handle API requests

Arguments

  • uri array - The request URI already parsed by parse_url()

Returns

  • bool - False if endpoint is not found. Should print the result.

reportShortcode

string tp\TouchPointWP\Report::reportShortcode(mixed params, string content)

Handle the report shortcode.

  • Visibility: public
  • This method is static.

Arguments

  • params mixed* content string

Returns

  • string -

getPost

\WP_Post|null tp\TouchPointWP\storedAsPost::getPost(bool create)

Get the WP_Post object corresponding to the object.

Arguments

  • create bool - Set true if the post should be created if it doesn't exist. This would need to be implemented in each module, and is not implemented in most.

Returns

  • \WP_Post|null -

content

string tp\TouchPointWP\Report::content(string contentIfError)

Get the report content. If no content is available, return the provided default content instead.

  • Visibility: public

Arguments

  • contentIfError string

Returns

  • string -

updateFromTouchPoint

int tp\TouchPointWP\Report::updateFromTouchPoint(bool forceEvenIfNotDue)

Update all reports from TouchPoint that are due for an update.

  • Visibility: public
  • This method is static.

Arguments

  • forceEvenIfNotDue bool

Returns

  • int -

needsUpdate

bool tp\TouchPointWP\Report::needsUpdate()

Determines if THIS report is due for an update. Does NOT process the update itself.

  • Visibility: public

Returns

  • bool -

updateCron

void tp\TouchPointWP\updatesViaCron::updateCron()

Run the updating cron task. Fail quietly to not disturb the visitor experience if using WP default cron handling.

jsonSerialize

array tp\TouchPointWP\Report::jsonSerialize()

Handle which data should be converted to JSON. Used for posting to the API.

  • Visibility: public

Returns

  • array - data which can be serialized by json_encode

checkUpdates

void tp\TouchPointWP\updatesViaCron::checkUpdates()

Check to see if a cron run is needed, and run it if so. Connected to an init function.