tp TouchPointWP Involvement - TenthPres/TouchPoint-WP GitHub Wiki
tp\TouchPointWP\Involvement
Fundamental object meant to correspond to an Involvement in TouchPoint
- Class name: Involvement
- Namespace: \tp\TouchPointWP
- Parent class: tp\TouchPointWP\PostTypeCapable
- This class implements: tp\TouchPointWP\api, tp\TouchPointWP\updatesViaCron, tp\TouchPointWP\hasGeo, tp\TouchPointWP\module, tp\TouchPointWP\hierarchical, JsonSerializable, tp\TouchPointWP\scheduled
Constants
SHORTCODE_MAP
const SHORTCODE_MAP = \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Inv-Map"
SHORTCODE_FILTER
const SHORTCODE_FILTER = \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Inv-Filters"
SHORTCODE_LIST
const SHORTCODE_LIST = \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Inv-List"
SHORTCODE_NEARBY
const SHORTCODE_NEARBY = \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Inv-Nearby"
SHORTCODE_ACTIONS
const SHORTCODE_ACTIONS = \tp\TouchPointWP\TouchPointWP::SHORTCODE_PREFIX . "Inv-Actions"
CRON_HOOK
const CRON_HOOK = \tp\TouchPointWP\TouchPointWP::HOOK_PREFIX . "inv_cron_hook"
CRON_OFFSET
const CRON_OFFSET = 86400 + 3600
Properties
containerClass
public mixed containerClass = 'inv-list'
- Visibility: public
itemClass
public mixed itemClass = 'inv-list-item'
- Visibility: public
color
public mixed color = "#999999"
- Visibility: public
name
public mixed name
- Visibility: public
invId
public mixed invId
- Visibility: public
invType
public invType
- Visibility: public
post_excerpt
public mixed post_excerpt
- Visibility: public
attributes
public mixed attributes
- Visibility: public
Methods
init
mixed tp\TouchPointWP\Involvement::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
updateFromTouchPoint
int tp\TouchPointWP\Involvement::updateFromTouchPoint(bool verbose)
Query TouchPoint and update Involvements in WordPress
- Visibility: public
- This method is static.
Arguments
- verbose bool - Whether to print debugging info.
Returns
- int - False on failure, or the number of groups that were updated or deleted.
templateFilter
string tp\TouchPointWP\Involvement::templateFilter(string template)
- Visibility: public
- This method is static.
Arguments
- template string
Returns
- string -
acceptingNewMembers
bool|string tp\TouchPointWP\Involvement::acceptingNewMembers()
Whether the involvement can be joined
- Visibility: public
Returns
- bool|string - True if involvement can be joined. False if no registration exists. Or, a string with why it can't be joined otherwise.
getRegistrationUrl
?string tp\TouchPointWP\Involvement::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.
- Visibility: public
Returns
- ?string -
getRegistrationType
int tp\TouchPointWP\Involvement::getRegistrationType()
Get the registration type for the involvement.
- Visibility: public
Returns
- int - enum of RegistrationType
useRegistrationForm
bool tp\TouchPointWP\Involvement::useRegistrationForm()
Whether the involvement should link to a registration form, rather than directly joining the org.
- Visibility: public
Returns
- bool -
getParent
mixed tp\TouchPointWP\hierarchical::getParent()
Get the parent of this object which may be an object of a different class.
Returns null if there is no parent.
- Visibility: public
- This method is defined by tp\TouchPointWP\hierarchical
Returns
- mixed -
scheduleString
?string tp\TouchPointWP\scheduled::scheduleString(int objId, mixed obj)
Get a description of the schedule in a human-friendly phrase, e.g. Sunday, March 31 at 2:00pm.
These strings should be cached.
- Visibility: public
- This method is static.
- This method is defined by tp\TouchPointWP\scheduled
Arguments
- objId int* obj mixed - Needs to be of the type that implements this interface.
Returns
- ?string -
nextMeeting
\tp\TouchPointWP\Utilities\DateTimeExtended|null tp\TouchPointWP\Involvement::nextMeeting()
Get the next meeting date/time from either the meetings or schedules.
- Visibility: public
Returns
- \tp\TouchPointWP\Utilities\DateTimeExtended|null -
getDivisionsStrings
string[] tp\TouchPointWP\Involvement::getDivisionsStrings()
Returns an array of the Involvement's Divisions, excluding those that cause it to be included.
- Visibility: public
Returns
- string[] -
getDivisionsLinks
string[] tp\TouchPointWP\Involvement::getDivisionsLinks()
Returns an array of links to the Involvement's Divisions, excluding those that cause it to be included.
- Visibility: public
Returns
- string[] -
getSettingsForPostType
?\tp\TouchPointWP\Involvement_PostTypeSettings tp\TouchPointWP\Involvement::getSettingsForPostType(?string postType)
Get the setting object for a specific post type or involvement type
- Visibility: public
- This method is static.
Arguments
- postType ?string - Accepts either the post type string, or the inv type string
Returns
- ?\tp\TouchPointWP\Involvement_PostTypeSettings -
getPostTypes
array tp\TouchPointWP\Involvement::getPostTypes()
Get an array of Involvement Post Types
- Visibility: public
- This method is static.
Returns
- array -
actionsShortcode
string tp\TouchPointWP\Involvement::actionsShortcode(array|string params, string content)
Display action buttons for an involvement. Takes an id parameter for the Involvement ID. If not provided, the current post will be used.
- Visibility: public
- This method is static.
Arguments
- params array|string* content string
Returns
- string -
filterShortcode
string tp\TouchPointWP\Involvement::filterShortcode(array|string params)
- Visibility: public
- This method is static.
Arguments
- params array|string
Returns
- string -
doInvolvementList
mixed tp\TouchPointWP\Involvement::doInvolvementList(\WP_Query q, mixed params)
- Visibility: public
- This method is static.
Arguments
- q WP_Query* params mixed
Returns
- mixed
listShortcode
string tp\TouchPointWP\Involvement::listShortcode(array|string params, string content)
Print a list of involvements that match the given criteria.
- Visibility: public
- This method is static.
Arguments
- params array|string* content string
Returns
- string -
nearbyShortcode
string tp\TouchPointWP\Involvement::nearbyShortcode(array|string params, string content)
- Visibility: public
- This method is static.
Arguments
- params array|string* content 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.
ajaxNearby
mixed tp\TouchPointWP\Involvement::ajaxNearby()
Handles the API call to get nearby involvements (probably small groups)
- Visibility: public
- This method is static.
Returns
- mixed
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 -
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
getDistance
float tp\TouchPointWP\Involvement::getDistance(bool useHiForFalse)
Returns distance to the given involvement from the $compareGeo point.
Math thanks to https://stackoverflow.com/a/574736/2339939
- Visibility: public
Arguments
- 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.
Returns
- float -
setComparisonGeo
mixed tp\TouchPointWP\Involvement::setComparisonGeo(object geo)
- Visibility: public
- This method is static.
Arguments
- geo object - Set a geo object to use for distance comparisons. Needs to be called before getDistance()
Returns
- mixed
sort
int tp\TouchPointWP\Involvement::sort(\tp\TouchPointWP\Involvement a, \tp\TouchPointWP\Involvement b)
Put SmallGroup objects in order of increasing distance. Closed groups go to the end.
- Visibility: public
- This method is static.
Arguments
Returns
- int -
sortPosts
int tp\TouchPointWP\Involvement::sortPosts(\WP_Post a, \WP_Post b)
Put Post objects that represent Small Groups in order of increasing distance.
- Visibility: public
- This method is static.
Arguments
- a WP_Post* b WP_Post
Returns
- int -
registerScriptsAndStyles
mixed tp\TouchPointWP\Involvement::registerScriptsAndStyles()
Register scripts and styles to be used on display pages.
- Visibility: public
- This method is static.
Returns
- mixed
mapShortcode
string tp\TouchPointWP\Involvement::mapShortcode(string|array params, string content)
- Visibility: public
- This method is static.
Arguments
- params string|array* content string
Returns
- string -
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 -
filterPublishDate
mixed tp\TouchPointWP\Involvement::filterPublishDate(mixed theDate, mixed format, mixed post)
Replace the date with the schedule summary
- Visibility: public
- This method is static.
Arguments
- theDate mixed* format mixed* post mixed
Returns
- mixed -
filterAuthor
string tp\TouchPointWP\Involvement::filterAuthor(mixed author)
Replace the author with the leaders
- Visibility: public
- This method is static.
Arguments
- author mixed - Author's display name
Returns
- string -
leaders
\tp\TouchPointWP\Utilities\PersonArray tp\TouchPointWP\Involvement::leaders()
Get the leaders of the Involvement
- Visibility: public
Returns
- \tp\TouchPointWP\Utilities\PersonArray -
hosts
?\tp\TouchPointWP\Utilities\PersonArray tp\TouchPointWP\Involvement::hosts()
Get the hosts of the involvement. Returns null if not a geo-enabled post type.
- Visibility: public
Returns
- ?\tp\TouchPointWP\Utilities\PersonArray -
members
?\tp\TouchPointWP\Utilities\PersonArray tp\TouchPointWP\Involvement::members()
Get the members of the involvement. Note that not all members are necessarily synced to WordPress from TouchPoint.
- Visibility: public
Returns
- ?\tp\TouchPointWP\Utilities\PersonArray -
toJsonLD
?object tp\TouchPointWP\Involvement::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).
- Visibility: public
- This method is abstract.
Returns
- ?object -
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 -
getRegisterButton
?string tp\TouchPointWP\Involvement::getRegisterButton(string btnClass, bool absoluteLinks, ?\tp\TouchPointWP\Meeting forMeeting)
Get the HTML for the register button. Labels depend on several settings within TouchPoint.
- Visibility: public
Arguments
- 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
Returns
- ?string - HTML for the registration button, whatever that should be. Null if nothing to return.
getJsInstantiationString
string tp\TouchPointWP\Involvement::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 -
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 -
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 -
getPermalink
string tp\TouchPointWP\Involvement::getPermalink()
Returns the permalink corresponding to the JSON-LD object.
- Visibility: public
Returns
- string -
printJsonLd
void tp\TouchPointWP\Involvement::printJsonLd()
Print the full JSON-LD info, including script tags.
- Visibility: public
- This method is static.
requireAllObjectsInJs
mixed tp\TouchPointWP\Involvement::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
jsonSerialize
object tp\TouchPointWP\Involvement::jsonSerialize()
Get the JS for instantiation.
- Visibility: public
Returns
- object -