Partner
in package
implements
api, JsonSerializable, updatesViaCron, geo, module
Uses
jsInstantiation, extraValues
An Outreach partner, corresponding to a family in TouchPoint.
Table of Contents
Interfaces
- api
- API Interface
- JsonSerializable
- updatesViaCron
- Interface to standardize items that are updated with Cron.
- geo
- For classes that have geographic attributes, or potential geographic attributes
- module
- This is a base interface for all feature classes.
Constants
- CRON_HOOK = \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "global_cron_hook"
- FAMILY_META_KEY = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . "famId"
- META_FEV_PREFIX = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . "fev_"
- POST_TYPE = \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "partner"
- SHORTCODE_ACTIONS = \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Partner-Actions"
- SHORTCODE_FILTER = \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Partner-Filters"
- SHORTCODE_LIST = \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Partner-List"
- SHORTCODE_MAP = \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Partner-Map"
Properties
- $attributes : object
- $color : string|null
- $containerClass : string
- $decoupleLocation : bool
- $geo : object|null
- $itemClass : string
- $name : string
- $post_excerpt : string
- $post_id : int
Methods
- actionsShortcode() : string
- Display action buttons for a partner. Takes an id parameter for the family ID. If not provided, the current post will be used.
- api() : bool
- Handle API requests
- asGeoIFace() : object|null
- Returns a standardized stdObject, or null if not viable.
- checkUpdates() : void
- Check to see if a cron run is needed, and run it if so. Connected to an init function.
- ExtraValues() : ExtraValueHandler|null
- filterAuthor() : string
- Prevents the author from being shown
- filterPublishDate() : string
- Replace the date with information that's relevant
- filterShortcode() : string
- fromPost() : Partner
- Create a Partner object from an object from a WP_Post object.
- getActionButtons() : string
- Returns the html with buttons for actions the user can perform. This must be called *within* an element with the `data-tp-partner` attribute with the post_id as the value or 0 for secure partners.
- getExtraValue() : mixed
- Get an Extra Value.
- getFamEvAsContent() : string|null
- Format an EV value for use as content.
- getJsInstantiationString() : string
- Get the JS for instantiation.
- getTouchPointId() : int
- Gets a TouchPoint item ID number, regardless of what type of object this is.
- hasGeo() : bool
- Indicates whether a map of a *single* Partner can be displayed.
- init() : void
- Register stuff
- jsId() : int
- Return the Post ID as needed by the JS classes. Typically, this will be the post_id, but this can be overridden.
- jsonSerialize() : object
- Serialize. Mostly, manage the security requirements.
- listShortcode() : string
- Display a list of the partners, as used in the templates.
- load() : bool
- Loads the module and initializes the other actions.
- mapShortcode() : string
- notableAttributes() : array<string|int, string>
- Get notable attributes as strings.
- registerScriptsAndStyles() : void
- Register scripts and styles to be used on display pages.
- requireAllObjectsInJs() : void
- If all objects need to be included in the JS,
- sort() : int
- Put Partner objects in order.
- sortPosts() : int
- Put Post objects that represent Partners in order of increasing distance.
- templateFilter() : string
- updateCron() : void
- Run the updating cron task. Fail quietly to not disturb the visitor experience if using WP default cron handling.
- updateFromTouchPoint() : false|int
- Query TouchPoint and update Partners in WordPress
Constants
CRON_HOOK
public
mixed
CRON_HOOK
= \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "global_cron_hook"
FAMILY_META_KEY
public
mixed
FAMILY_META_KEY
= \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . "famId"
META_FEV_PREFIX
public
mixed
META_FEV_PREFIX
= \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . "fev_"
POST_TYPE
public
mixed
POST_TYPE
= \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "partner"
SHORTCODE_ACTIONS
public
mixed
SHORTCODE_ACTIONS
= \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Partner-Actions"
SHORTCODE_FILTER
public
mixed
SHORTCODE_FILTER
= \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Partner-Filters"
SHORTCODE_LIST
public
mixed
SHORTCODE_LIST
= \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Partner-List"
SHORTCODE_MAP
public
mixed
SHORTCODE_MAP
= \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Partner-Map"
Properties
$attributes
public
object
$attributes
$color
public
string|null
$color
= "#999999"
$containerClass
public
static string
$containerClass
= 'partner-list'
$decoupleLocation
public
bool
$decoupleLocation
$geo
public
object|null
$geo
= null
$itemClass
public
static string
$itemClass
= 'partner-list-item'
$name
public
string
$name
$post_excerpt
public
string
$post_excerpt
$post_id
public
int
$post_id
Methods
actionsShortcode()
Display action buttons for a partner. Takes an id parameter for the family ID. If not provided, the current post will be used.
public
static actionsShortcode([array<string|int, mixed>|string $params = [] ][, string $content = "" ]) : string
Parameters
- $params : array<string|int, mixed>|string = []
- $content : string = ""
Return values
stringapi()
Handle API requests
public
static api(array<string|int, mixed> $uri) : bool
Parameters
- $uri : array<string|int, mixed>
-
The request URI already parsed by parse_url()
Return values
bool —False if endpoint is not found. Should print the result.
asGeoIFace()
Returns a standardized stdObject, or null if not viable.
public
asGeoIFace([string $type = "unknown" ]) : object|null
Return object properties are lat, lng, human, and type.
Parameters
- $type : string = "unknown"
-
'loc' for navigator location, or 'ip' for ip address location
Return values
object|nullcheckUpdates()
Check to see if a cron run is needed, and run it if so. Connected to an init function.
public
static checkUpdates() : void
ExtraValues()
public
ExtraValues() : ExtraValueHandler|null
Return values
ExtraValueHandler|nullfilterAuthor()
Prevents the author from being shown
public
static filterAuthor( $author) : string
Parameters
Tags
Return values
stringfilterPublishDate()
Replace the date with information that's relevant
public
static filterPublishDate( $theDate, $format[, $post = null ]) : string
Parameters
Tags
Return values
stringfilterShortcode()
public
static filterShortcode([array<string|int, mixed>|string $params = [] ]) : string
Parameters
- $params : array<string|int, mixed>|string = []
Return values
stringfromPost()
Create a Partner object from an object from a WP_Post object.
public
static fromPost(WP_Post $post) : Partner
Parameters
- $post : WP_Post
Tags
Return values
PartnergetActionButtons()
Returns the html with buttons for actions the user can perform. This must be called *within* an element with the `data-tp-partner` attribute with the post_id as the value or 0 for secure partners.
public
getActionButtons([string|null $context = null ][, string $btnClass = "" ]) : string
Parameters
- $context : string|null = null
-
A reference to where the action buttons are meant to be used.
- $btnClass : string = ""
-
A string for classes to add to the buttons. Note that buttons can be a or button elements.
Return values
stringgetExtraValue()
Get an Extra Value.
public
abstract getExtraValue(string $name) : mixed
Parameters
- $name : string
-
The name of the extra value to get.
Return values
mixed —The value of the extra value. Returns null if it doesn't exist.
getFamEvAsContent()
Format an EV value for use as content.
public
static getFamEvAsContent(string $ev, object $famObj, string|null $default) : string|null
Parameters
- $ev : string
-
The name of the extra value
- $famObj : object
-
The family object from the API call
- $default : string|null
-
Value to use if no content is provided in the EV.
Return values
string|nullgetJsInstantiationString()
Get the JS for instantiation.
public
abstract static getJsInstantiationString() : string
Return values
stringgetTouchPointId()
Gets a TouchPoint item ID number, regardless of what type of object this is.
public
abstract getTouchPointId() : int
Return values
inthasGeo()
Indicates whether a map of a *single* Partner can be displayed.
public
hasGeo() : bool
Return values
boolinit()
Register stuff
public
static init() : void
jsId()
Return the Post ID as needed by the JS classes. Typically, this will be the post_id, but this can be overridden.
public
jsId() : int
Return values
intjsonSerialize()
Serialize. Mostly, manage the security requirements.
public
jsonSerialize() : object
Return values
objectlistShortcode()
Display a list of the partners, as used in the templates.
public
static listShortcode([array<string|int, mixed>|string $params = [] ][, string $content = "" ]) : string
Parameters
- $params : array<string|int, mixed>|string = []
- $content : string = ""
Tags
Return values
stringload()
Loads the module and initializes the other actions.
public
static load() : bool
Return values
boolmapShortcode()
public
static mapShortcode([string|array<string|int, mixed> $params = [] ][, string $content = "" ]) : string
Parameters
- $params : string|array<string|int, mixed> = []
- $content : string = ""
Tags
Return values
stringnotableAttributes()
Get notable attributes as strings.
public
notableAttributes() : array<string|int, string>
Return values
array<string|int, string>registerScriptsAndStyles()
Register scripts and styles to be used on display pages.
public
static registerScriptsAndStyles() : void
requireAllObjectsInJs()
If all objects need to be included in the JS,
public
static requireAllObjectsInJs([bool $require = true ]) : void
Parameters
- $require : bool = true
-
Whether all objects should be required. Almost always should be left with the default.
sort()
Put Partner objects in order.
public
static sort(Partner $a, Partner $b) : int
Parameters
Return values
intsortPosts()
Put Post objects that represent Partners in order of increasing distance.
public
static sortPosts(WP_Post $a, WP_Post $b) : int
Parameters
- $a : WP_Post
- $b : WP_Post
Return values
inttemplateFilter()
public
static templateFilter(string $template) : string
Parameters
- $template : string
Tags
Return values
stringupdateCron()
Run the updating cron task. Fail quietly to not disturb the visitor experience if using WP default cron handling.
public
static updateCron() : void
updateFromTouchPoint()
Query TouchPoint and update Partners in WordPress
public
static updateFromTouchPoint([bool $verbose = false ]) : false|int
Parameters
- $verbose : bool = false
-
Whether to print debugging info.
Tags
Return values
false|int —False on failure, or the number of partner posts that were updated or deleted.