tp TouchPointWP Involvement - TenthPres/TouchPoint-WP GitHub Wiki
tp\TouchPointWP\Involvement
Fundamental object meant to correspond to an Involvement in TouchPoint
- Full name:
\tp\TouchPointWP\Involvement - Parent class:
\tp\TouchPointWP\PostTypeCapable - This class implements:
\tp\TouchPointWP\Interfaces\api,\tp\TouchPointWP\Interfaces\updatesViaCron,\tp\TouchPointWP\Interfaces\module,JsonSerializable,\tp\TouchPointWP\Interfaces\involvementMeetingCommon
Constants
| Constant | Visibility | Type | Value |
|---|---|---|---|
SHORTCODE_MAP |
public | \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Inv-Map" | |
SHORTCODE_FILTER |
public | \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Inv-Filters" | |
SHORTCODE_LIST |
public | \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Inv-List" | |
SHORTCODE_NEARBY |
public | \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Inv-Nearby" | |
SHORTCODE_ACTIONS |
public | \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Inv-Actions" | |
POST_STATUS_HIDDEN |
public | \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "hidden_resource" | |
CRON_HOOK |
public | \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "inv_cron_hook" | |
CRON_OFFSET |
public | 86400 - 3600 |
Properties
containerClass
public static string $containerClass
- This property is static.
itemClass
public static string $itemClass
- This property is static.
color
public ?string $color
name
public string $name
invId
public int $invId
invType
public string $invType
post_excerpt
public string $post_excerpt
attributes
public object $attributes
Methods
allTypeSettings
Get the settings array of objects for Involvement Post Types
final public static allTypeSettings(): \tp\TouchPointWP\Involvement_PostTypeSettings[]
Was previously protected, but that doesn't make sense since the underlying function isn't.
- This method is static.* This method is final.
init
Register stuff
public static init(): void
- This method is static.
checkUpdates
Check to see if a cron run is needed, and run it if so. Connected to an init function.
public static checkUpdates(): void
- This method is static.
updateFromTouchPoint
Query TouchPoint and update Involvements in WordPress
final public static updateFromTouchPoint(?string $typeSlug = null, bool $verbose = false, bool $applyChanges = true): int
- This method is static.* This method is final. Parameters:
| Parameter | Type | Description |
|---|---|---|
$typeSlug |
?string | |
$verbose |
bool | Whether to print debugging info. |
$applyChanges |
bool |
Return Value:
False on failure, or the number of groups that were updated or deleted.
templateFilter
public static templateFilter(string $template): string
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$template |
string |
acceptingNewMembers
Whether the involvement can be joined
public acceptingNewMembers(): bool|string
Return Value:
True if involvement can be joined. False if no registration exists. Or, a string with why it can't be joined otherwise.
getRegistrationUrl
Gets a URL for registration. A registration url will be provided unless there is no viable registration url to send users to, in which case null will be returned.
public getRegistrationUrl(): ?string
getRegistrationType
Get the registration type for the involvement.
public getRegistrationType(): int
Return Value:
enum of RegistrationType
useRegistrationForm
Whether the involvement should link to a registration form, rather than directly joining the org.
public useRegistrationForm(): bool
- Warning: this method is deprecated. This means that this method will likely be removed in a future version.
getParent
Get the parent of this object which may be an object of a different class.
public getParent(): \tp\TouchPointWP\Involvement|null
Returns null if there is no parent.
scheduleString
Get a description of the meeting schedule in a human-friendly phrase, e.g. Sundays at 11:00am, starting January 14.
public static scheduleString(int $objId, ?\tp\TouchPointWP\Involvement $obj = null): ?string
This is separated out to a static method to prevent involvement from being instantiated (with those database hits) when the content is cached. (10x faster or more)
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$objId |
int | Involvement Id. |
$obj |
?\tp\TouchPointWP\Involvement |
nextMeeting
Get the next meeting date/time from either the meetings or schedules.
public nextMeeting(): \tp\TouchPointWP\Utilities\DateTimeExtended|null
getDivisionsStrings
Returns an array of the Involvement's Divisions, excluding those that cause it to be included.
public getDivisionsStrings(): string[]
getDivisionsLinks
Returns an array of links to the Involvement's Divisions, excluding those that cause it to be included.
public getDivisionsLinks(): string[]
getSettingsForPostType
Get the setting object for a specific post type or involvement type
public static getSettingsForPostType(?string $postType): ?\tp\TouchPointWP\Involvement_PostTypeSettings
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$postType |
?string | Accepts either the post type string, or the inv type string |
getPostTypes
Get an array of Involvement Post Types
public static getPostTypes(): array
- This method is static.
getPostTypesSummary
Get an array of Involvement Post Types, with some basic info
public static getPostTypesSummary(): array[]
- This method is static.
actionsShortcode
Display action buttons for an involvement. Takes an id parameter for the Involvement ID. If not provided, the current post will be used.
public static actionsShortcode(array|string $params = [], string $content = ""): string
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$params |
array|string | |
$content |
string |
filterShortcode
public static filterShortcode(array|string $params = []): string
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$params |
array|string |
doInvolvementList
public static doInvolvementList(\WP_Query $q, mixed $params = []): void
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$q |
\WP_Query | |
$params |
mixed |
listShortcode
Print a list of involvements that match the given criteria.
public static listShortcode(array|string $params = [], string $content = ""): string
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$params |
array|string | |
$content |
string | A string that is shown if no content is available. |
nearbyShortcode
public static nearbyShortcode(array|string $params = [], string $content = ""): string
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$params |
array|string | |
$content |
string |
fromPost
Create an Involvement object from an object from a WP_Post object.
public static fromPost(\WP_Post $post): ?\tp\TouchPointWP\Involvement
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$post |
\WP_Post |
Throws:
If the involvement can't be created from the post, an exception is thrown.
fromInvolvementId
Create an Involvement object from an object from its involvement ID.
public static fromInvolvementId(string $postType, int $involvementId): ?\tp\TouchPointWP\Involvement
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$postType |
string | |
$involvementId |
int |
Throws:
If the involvement can't be created, an exception is thrown.
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.
ajaxNearby
Handles the API call to get nearby involvements (probably small groups)
public static ajaxNearby(): void
- This method is static.
load
Loads the module and initializes the other actions.
public static load(): bool
- This method is static.
updateCron
Run the updating cron task. Fail quietly to not disturb the visitor experience if using WP default cron handling.
public static updateCron(): void
- This method is static.
getDistance
Returns distance to the given involvement from the $compareGeo point.
public getDistance(bool $useHiForFalse = false): float
Math thanks to https://stackoverflow.com/a/574736/2339939
Parameters:
| Parameter | Type | Description |
|---|---|---|
$useHiForFalse |
bool | Set to true if a high number should be used for distances that can't be computed. |
| Used for sorting by distance with the closest first. |
setComparisonGeo
public static setComparisonGeo(object $geo): void
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$geo |
object | Set a geo object to use for distance comparisons. Needs to be called before getDistance() |
sort
Put SmallGroup objects in order of increasing distance. Closed groups go to the end.
public static sort(\tp\TouchPointWP\Involvement $a, \tp\TouchPointWP\Involvement $b): int
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$a |
\tp\TouchPointWP\Involvement | |
$b |
\tp\TouchPointWP\Involvement |
sortPosts
Put Post objects that represent Small Groups in order of increasing distance.
public static sortPosts(\WP_Post|\tp\TouchPointWP\Involvement $a, \WP_Post|\tp\TouchPointWP\Involvement $b): int
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$a |
\WP_Post|\tp\TouchPointWP\Involvement | |
$b |
\WP_Post|\tp\TouchPointWP\Involvement |
registerScriptsAndStyles
Register scripts and styles to be used on display pages.
public static registerScriptsAndStyles(): void
- This method is static.
mapShortcode
public static mapShortcode(string|array $params = [], string $content = ""): string
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$params |
string|array | |
$content |
string |
hasGeo
Indicates whether a map of a single Involvement can be displayed.
public hasGeo(): bool
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:
| Parameter | Type | Description |
|---|---|---|
$type |
string | 'loc' for navigator location, or 'ip' for ip address location |
filterThumbnailId
Give a post the featured image of its nearest ancestor that has one, if it doesn't have one of its own. This is done when the image is requested, and nothing is copied to the child, so the child follows its parent's image when that changes.
public static filterThumbnailId(int|false $thumbnailId, int|\WP_Post|null $post = null): int|false
Meetings and meeting groups that are archived (see Archive After Days) are left as they are, since their content is frozen, and an event from a past year shouldn't pick up an image from the current one.
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$thumbnailId |
int|false | The post's own thumbnail ID, or 0 or false if it has none. |
$post |
int|\WP_Post|null | The post. Default is the global post. |
filterPublishDate
Replace the date with the schedule summary
public static filterPublishDate(mixed $theDate, mixed $format, mixed $post = null): mixed
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$theDate |
mixed | |
$format |
mixed | |
$post |
mixed |
filterAuthor
Replace the author with the leaders
public static filterAuthor(mixed $author): string
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$author |
mixed | Author's display name |
leaders
Get the leaders of the Involvement
public leaders(): \tp\TouchPointWP\Utilities\PersonArray
hosts
Get the hosts of the involvement. Returns null if not a geo-enabled post type.
public hosts(): ?\tp\TouchPointWP\Utilities\PersonArray
members
Get the members of the involvement. Note that not all members are necessarily synced to WordPress from TouchPoint.
public members(): ?\tp\TouchPointWP\Utilities\PersonArray
toJsonLD
return an object that turns into JSON-LD as an event, compliant with schema.org
public toJsonLD(): ?array
notableAttributes
Get notable attributes, such as gender restrictions, as strings.
public notableAttributes(array|\tp\TouchPointWP\Utilities\StringableArray $exclude = []): \tp\TouchPointWP\Utilities\NotableAttributes
Parameters:
| Parameter | Type | Description |
|---|---|---|
$exclude |
array|\tp\TouchPointWP\Utilities\StringableArray | Attributes listed here will be excluded. (e.g. if shown for a parent inv, |
| not needed here.) |
getActionButtons
Returns the html with buttons for actions the user can perform. This must be called within an element with
the data-tp-involvement attribute with the post_id (NOT the Inv ID) as the value.
public getActionButtons(string|null $context = null, string $btnClass = "", bool $withTouchPointLink = true, bool $absoluteLinks = false, bool $includeRegister = true): \tp\TouchPointWP\Utilities\StringableArray
Parameters:
| Parameter | Type | Description |
|---|---|---|
$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. |
$includeRegister |
bool | Set false to exclude the register button. |
getRegisterButton
Get the HTML for the register button. Labels depend on several settings within TouchPoint.
public getRegisterButton(string $btnClass, bool $absoluteLinks = false, ?\tp\TouchPointWP\Meeting $forMeeting = null): ?string
Parameters:
| Parameter | Type | Description |
|---|---|---|
$btnClass |
string | Class names |
$absoluteLinks |
bool | Whether only absolute links should be provided that can be used in emails, apps, |
| etc. | ||
$forMeeting |
?\tp\TouchPointWP\Meeting | If these buttons are for a meeting, pass the meeting |
Return Value:
HTML for the registration button, whatever that should be. Null if nothing to return.
isPast
Indicates if the meeting is in the past.
public isPast(): bool
getJsInstantiationString
Get the JS for instantiation.
public static getJsInstantiationString(): string
- This method is static.
getTouchPointId
Gets a TouchPoint item ID number, regardless of what type of object this is.
public getTouchPointId(): int
postIsType
Indicates if the given post can be instantiated as an Involvement.
public static postIsType(\WP_Post $post): bool
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$post |
\WP_Post |
postTypeMatches
Indicates if the given post type name is the post type for this class.
public static postTypeMatches(string $postType): bool
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$postType |
string |
locationName
Get the name of the location.
public locationName(): ?string
Inherited methods
post_id
Get the Post_id.
public post_id(): int
getPost
Get the WP_Post object corresponding to the object.
public getPost(bool $create = false): \WP_Post|null
Parameters:
| Parameter | Type | Description |
|---|---|---|
$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. |
fromPost
Create relevant objects from a given post
public static fromPost(\WP_Post $post): ?\tp\TouchPointWP\PostTypeCapable
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$post |
\WP_Post |
Throws:
permalink
Get the link for the post.
public permalink(): string
titleWithinParent
Get the title for display within its parent, such as in the parent's list of its parts. If the title starts with the parent's title and a separator, the parent's title is left out, since the parent's title is already visible: "Global Outreach Conference: Q&A Luncheon" is displayed as "Q&A Luncheon" within "Global Outreach Conference". The stored title isn't changed.
public titleWithinParent(?\WP_Post $parent = null): string
The result is filtered like any other title, so it can be printed in place of the_title().
Parameters:
| Parameter | Type | Description |
|---|---|---|
$parent |
?\WP_Post | The parent to display this within. Default is its own parent. |
titleInList
Get the title for display in a list. If the list is on the page of this one's parent, this is the title within its parent (see titleWithinParent()). Otherwise, such as in an archive or a list on some other page, this is displayed on its own, and its full title is needed.
public titleInList(): string
notableAttributes
Get notable attributes.
public notableAttributes(array|\tp\TouchPointWP\Utilities\StringableArray $exclude = []): \tp\TouchPointWP\Utilities\NotableAttributes
- This method is abstract. Parameters:
| Parameter | Type | Description |
|---|---|---|
$exclude |
array|\tp\TouchPointWP\Utilities\StringableArray | Attributes listed here will be excluded. (e.g. if shown for a parent, not needed here.) |
postIsType
Indicates if the given post can be instantiated as the given post type.
public static postIsType(\WP_Post $post): bool
- This method is static.* This method is abstract. Parameters:
| Parameter | Type | Description |
|---|---|---|
$post |
\WP_Post |
postTypeMatches
Indicates if the given post type name is the post type for this class.
public static postTypeMatches(string $postType): bool
- This method is static.* This method is abstract. Parameters:
| Parameter | Type | Description |
|---|---|---|
$postType |
string |
getTouchPointId
Gets a TouchPoint item ID number, regardless of what type of object this is.
public getTouchPointId(): int
- This method is abstract.
getPermalink
Returns the permalink corresponding to the JSON-LD object.
public getPermalink(): string
toJsonLD
Return an object that turns into JSON-LD as an event, compliant with schema.org. Return null if the object can't be printed to jsonLd for some reason (e.g. required fields are missing).
public toJsonLD(): ?object
- This method is abstract.
printJsonLd
Print the full JSON-LD info, including script tags.
public static printJsonLd(): void
- This method is static.
requireAllObjectsInJs
If all objects need to be included in the JS,
public static requireAllObjectsInJs(bool $require = true): void
- This method is static. Parameters:
| Parameter | Type | Description |
|---|---|---|
$require |
bool | Whether all objects should be required. Almost always should be left with the default. |
jsonSerialize
Get the JS for instantiation.
public jsonSerialize(): object
getJsInstantiationString
Get the JS for instantiation.
public static getJsInstantiationString(): string
- This method is static.* This method is abstract.