tp TouchPointWP Partner - TenthPres/TouchPoint-WP GitHub Wiki
tp\TouchPointWP\Partner
An Outreach partner, corresponding to a family in TouchPoint.
- Class name: Partner
- Namespace: \tp\TouchPointWP
- Parent class: tp\TouchPointWP\PostTypeCapable
- This class implements: tp\TouchPointWP\api, JsonSerializable, tp\TouchPointWP\updatesViaCron, tp\TouchPointWP\hasGeo, tp\TouchPointWP\module
Constants
SHORTCODE_MAP
const SHORTCODE_MAP = \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Partner-Map"
SHORTCODE_FILTER
const SHORTCODE_FILTER = \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Partner-Filters"
SHORTCODE_ACTIONS
const SHORTCODE_ACTIONS = \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Partner-Actions"
SHORTCODE_LIST
const SHORTCODE_LIST = \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Partner-List"
CRON_HOOK
const CRON_HOOK = \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "global_cron_hook"
FAMILY_META_KEY
const FAMILY_META_KEY = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . "famId"
POST_TYPE
const POST_TYPE = \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "partner"
META_FEV_PREFIX
const META_FEV_PREFIX = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . "fev_"
Properties
containerClass
public mixed containerClass = 'partner-list'
- Visibility: public
itemClass
public mixed itemClass = 'partner-list-item'
- Visibility: public
geo
public mixed geo = null
- Visibility: public
decoupleLocation
public mixed decoupleLocation
- Visibility: public
color
public mixed color = "#999999"
- Visibility: public
name
public mixed name
- Visibility: public
attributes
public mixed attributes
- Visibility: public
Methods
init
mixed tp\TouchPointWP\Partner::init()
Register stuff
- Visibility: public
- This method is static.
Returns
- mixed
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.
- Visibility: public
- This method is static.
- This method is defined by tp\TouchPointWP\updatesViaCron
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.
- Visibility: public
- This method is static.
- This method is defined by tp\TouchPointWP\updatesViaCron
updateFromTouchPoint
false|int tp\TouchPointWP\Partner::updateFromTouchPoint(bool verbose)
Query TouchPoint and update Partners in WordPress
- Visibility: public
- This method is static.
Arguments
- verbose bool - Whether to print debugging info.
Returns
- false|int - False on failure, or the number of partner posts that were updated or deleted.
templateFilter
string tp\TouchPointWP\Partner::templateFilter(string template)
- Visibility: public
- This method is static.
Arguments
- template string
Returns
- string -
actionsShortcode
string tp\TouchPointWP\Partner::actionsShortcode(array|string params, string content)
Display action buttons for a partner. Takes an id parameter for the family ID. If not provided, the current post will be used.
- Visibility: public
- This method is static.
Arguments
- params array|string* content string
Returns
- string -
listShortcode
string tp\TouchPointWP\Partner::listShortcode(array|string params, string content)
Display a list of the partners, as used in the templates.
- Visibility: public
- This method is static.
Arguments
- params array|string* content string
Returns
- string -
filterShortcode
string tp\TouchPointWP\Partner::filterShortcode(array|string params)
- Visibility: public
- This method is static.
Arguments
- params array|string
Returns
- string -
fromPost
?\tp\TouchPointWP\PostTypeCapable tp\TouchPointWP\PostTypeCapable::fromPost(\WP_Post post)
Create relevant objects from a given post
- Visibility: public
- This method is static.
- This method is defined by tp\TouchPointWP\PostTypeCapable
Arguments
- post WP_Post
Returns
- ?\tp\TouchPointWP\PostTypeCapable -
api
bool tp\TouchPointWP\api::api(array uri)
Handle API requests
- Visibility: public
- This method is static.
- This method is defined by tp\TouchPointWP\api
Arguments
- uri array - The request URI already parsed by parse_url()
Returns
- bool - False if endpoint is not found. Should print the result.
load
bool tp\TouchPointWP\module::load()
Loads the module and initializes the other actions.
- Visibility: public
- This method is static.
- This method is defined by tp\TouchPointWP\module
Returns
- bool -
sort
int tp\TouchPointWP\Partner::sort(\tp\TouchPointWP\Partner a, \tp\TouchPointWP\Partner b)
Put Partner objects in order.
- Visibility: public
- This method is static.
Arguments
Returns
- int -
sortPosts
int tp\TouchPointWP\Partner::sortPosts(\WP_Post a, \WP_Post b)
Put Post objects that represent Partners in order of increasing distance.
- Visibility: public
- This method is static.
Arguments
- a WP_Post* b WP_Post
Returns
- int -
registerScriptsAndStyles
mixed tp\TouchPointWP\Partner::registerScriptsAndStyles()
Register scripts and styles to be used on display pages.
- Visibility: public
- This method is static.
Returns
- mixed
mapShortcode
string tp\TouchPointWP\Partner::mapShortcode(string|array params, string content)
- Visibility: public
- This method is static.
Arguments
- params string|array* content string
Returns
- string -
filterPublishDate
string tp\TouchPointWP\Partner::filterPublishDate(mixed theDate, mixed format, mixed post)
Replace the date with information that's relevant
- Visibility: public
- This method is static.
Arguments
- theDate mixed* format mixed* post mixed
Returns
- string -
filterAuthor
string tp\TouchPointWP\Partner::filterAuthor(mixed author)
Prevents the author from being shown
- Visibility: public
- This method is static.
Arguments
- author mixed
Returns
- string -
getFamEvAsContent
?string tp\TouchPointWP\Partner::getFamEvAsContent(string ev, object famObj, ?string default)
Format an EV value for use as content.
- Visibility: public
- This method is static.
Arguments
- ev string - The name of the extra value
- famObj object - The family object from the API call
- default ?string - Value to use if no content is provided in the EV.
Returns
- ?string -
notableAttributes
string[] tp\TouchPointWP\PostTypeCapable::notableAttributes(array exclude)
Get notable attributes.
- Visibility: public
- This method is abstract.
- This method is defined by tp\TouchPointWP\PostTypeCapable
Arguments
- exclude array - Attributes listed here will be excluded. (e.g. if shown for a parent, not needed here.)
Returns
- string[] -
getActionButtons
\tp\TouchPointWP\Utilities\StringableArray tp\TouchPointWP\PostTypeCapable::getActionButtons(string|null context, string btnClass, bool withTouchPointLink, bool absoluteLinks)
- Visibility: public
- This method is abstract.
- This method is defined by tp\TouchPointWP\PostTypeCapable
Arguments
- context string|null - A string that gives filters some context for where the request is coming from
- btnClass string - HTML class names to put into the buttons/links
- withTouchPointLink bool - Whether to include a link to the item within TouchPoint.
- absoluteLinks bool - Set true to make the links absolute, so they work from apps or emails.
Returns
- \tp\TouchPointWP\Utilities\StringableArray -
getJsInstantiationString
string tp\TouchPointWP\Partner::getJsInstantiationString()
Get the JS for instantiation.
- Visibility: public
- This method is abstract.
- This method is static.
Returns
- string -
getTouchPointId
int tp\TouchPointWP\PostTypeCapable::getTouchPointId()
Gets a TouchPoint item ID number, regardless of what type of object this is.
- Visibility: public
- This method is abstract.
- This method is defined by tp\TouchPointWP\PostTypeCapable
Returns
- int -
jsId
int tp\TouchPointWP\Partner::jsId()
Return the Post ID as needed by the JS classes. Typically, this will be the post_id, but this can be overridden.
- Visibility: public
Returns
- int -
getExtraValue
mixed tp\TouchPointWP\Partner::getExtraValue(string name)
Get an Extra Value.
- Visibility: public
- This method is abstract.
Arguments
- name string - The name of the extra value to get.
Returns
- mixed - The value of the extra value. Returns null if it doesn't exist.
postIsType
bool tp\TouchPointWP\PostTypeCapable::postIsType(\WP_Post post)
Indicates if the given post can be instantiated as the given post type.
- Visibility: public
- This method is abstract.
- This method is static.
- This method is defined by tp\TouchPointWP\PostTypeCapable
Arguments
- post WP_Post
Returns
- bool -
jsonSerialize
object tp\TouchPointWP\Partner::jsonSerialize()
Get the JS for instantiation.
- Visibility: public
Returns
- object -
hasGeo
bool tp\TouchPointWP\hasGeo::hasGeo()
Indicates whether a map of a single item can be displayed.
- Visibility: public
- This method is defined by tp\TouchPointWP\hasGeo
Returns
- bool -
asGeoIFace
object|null tp\TouchPointWP\hasGeo::asGeoIFace(string type)
Returns a standardized stdObject, or null if not viable.
Return object properties are lat, lng, human, and type.
- Visibility: public
- This method is defined by tp\TouchPointWP\hasGeo
Arguments
- type string - 'loc' for navigator location, or 'ip' for ip address location
Returns
- object|null -
locationName
?string tp\TouchPointWP\hasGeo::locationName()
Get the name of the location.
- Visibility: public
- This method is defined by tp\TouchPointWP\hasGeo
Returns
- ?string -
post_id
int tp\TouchPointWP\PostTypeCapable::post_id()
Get the Post_id.
- Visibility: public
- This method is defined by tp\TouchPointWP\PostTypeCapable
Returns
- int -
getPost
\WP_Post|null tp\TouchPointWP\storedAsPost::getPost(bool create)
Get the WP_Post object corresponding to the object.
- Visibility: public
- This method is defined by tp\TouchPointWP\storedAsPost
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 -
permalink
string tp\TouchPointWP\PostTypeCapable::permalink()
Get the link for the post.
- Visibility: public
- This method is defined by tp\TouchPointWP\PostTypeCapable
Returns
- string -
ExtraValues
?\tp\TouchPointWP\ExtraValueHandler tp\TouchPointWP\Partner::ExtraValues()
- Visibility: public
Returns
- ?\tp\TouchPointWP\ExtraValueHandler -
requireAllObjectsInJs
mixed tp\TouchPointWP\Partner::requireAllObjectsInJs(bool require)
If all objects need to be included in the JS,
- Visibility: public
- This method is static.
Arguments
- require bool - Whether all objects should be required. Almost always should be left with the default.
Returns
- mixed