-
Notifications
You must be signed in to change notification settings - Fork 2
tp TouchPointWP Utilities
A few tools for managing things.
- Class name: Utilities
- Namespace: \tp\TouchPointWP
- This is an abstract class
const PLUGIN_UPDATE_TRANSIENT = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . "plugin_update_data"
const PLUGIN_UPDATE_TRANSIENT_TTL = 43200
float|null tp\TouchPointWP\Utilities::toFloatOrNull(mixed numeric, bool|int round)
- Visibility: public
- This method is static.
- numeric mixed* round bool|int - False to skip rounding. Otherwise, precision passed to round().
- float|null -
\DateTimeImmutable tp\TouchPointWP\Utilities::dateTimeNow()
- Visibility: public
- This method is static.
- \DateTimeImmutable -
\DateTimeImmutable tp\TouchPointWP\Utilities::dateTimeTodayAtMidnight()
- Visibility: public
- This method is static.
- \DateTimeImmutable -
\DateTimeImmutable tp\TouchPointWP\Utilities::dateTimeNowPlus1Y()
- Visibility: public
- This method is static.
- \DateTimeImmutable -
\DateTimeImmutable tp\TouchPointWP\Utilities::dateTimeNowPlus90D()
- Visibility: public
- This method is static.
- \DateTimeImmutable -
\DateTimeImmutable tp\TouchPointWP\Utilities::dateTimeNowPlus1D()
- Visibility: public
- This method is static.
- \DateTimeImmutable -
\DateTimeImmutable tp\TouchPointWP\Utilities::dateTimeNowMinus1D()
- Visibility: public
- This method is static.
- \DateTimeImmutable -
\DateTimeZone tp\TouchPointWP\Utilities::utcTimeZone()
- Visibility: public
- This method is static.
- \DateTimeZone -
string tp\TouchPointWP\Utilities::getPluralDayOfWeekNameForNumber(int dayNum)
Gets the plural form of a weekday name.
- Visibility: public
- This method is static.
- dayNum int
- string - Plural weekday (e.g. Mondays)
string tp\TouchPointWP\Utilities::getPluralDayOfWeekNameForNumber_noI18n(int dayNum)
Gets the plural form of a weekday name, but without translation for use in places like slugs.
- Visibility: public
- This method is static.
- dayNum int
- string - Plural weekday (e.g. Mondays)
string tp\TouchPointWP\Utilities::getDayOfWeekShortForNumber(int dayNum)
- Visibility: public
- This method is static.
- dayNum int
- string -
string[] tp\TouchPointWP\Utilities::getDaysOfWeekShort()
Get the short form of the day of week, translated. Assumed to be usable as both singular and plural.
- Visibility: public
- This method is static.
- string[] -
string tp\TouchPointWP\Utilities::getDayOfWeekShortForNumber_noI18n(int dayNum)
NOT internationalized, such as for slugs
- Visibility: public
- This method is static.
- dayNum int
- string -
string tp\TouchPointWP\Utilities::getTimeOfDayTermForTime(\DateTimeInterface dt, bool i18n)
Gets the non-specific time of day in words.
Translation: These are deliberately not scoped to TouchPoint-WP, so if the translation exists globally, it should work here.
- Visibility: public
- This method is static.
- dt DateTimeInterface* i18n bool
- string -
mixed tp\TouchPointWP\Utilities::getTimeOfDayTermForTime_noI18n(\DateTimeInterface dt)
- Visibility: public
- This method is static.
- dt DateTimeInterface
- mixed
string tp\TouchPointWP\Utilities::stringArrayToListString(string[] strings, int limit, bool andOthers)
Join an array of strings into a properly-formatted (English-style) list. Uses commas and ampersands by default.
This will switch to written "and" when an ampersand is present in a string, and will use semi-colons instead of commas when commas are already present.
Turn ['apples', 'oranges', 'pears'] into "apples, oranges & pears"
- Visibility: public
- This method is static.
- strings string[]* limit int - The maximum number of items to include. Default is very, very high.
- andOthers bool - If true, the last item will be "others" instead of the actual last item.
- string -
int[]|string tp\TouchPointWP\Utilities::idArrayToIntArray(array|string r, bool explode)
Convert a list (string or array) to an int array. Strips out non-numerics and explodes.
- Visibility: public
- This method is static.
- r array|string* explode bool
- int[]|string -
string[] tp\TouchPointWP\Utilities::getRegisteredPostTypesAsKVArray()
Get the registered post types as a Key-Value array. Excludes post types that start with 'tp_'.
- Visibility: public
- This method is static.
- string[] -
string tp\TouchPointWP\Utilities::createGuid()
Generates a Microsoft-friendly globally unique identifier (Guid).
- Visibility: public
- This method is static.
- string - A new random globally unique identifier.
void tp\TouchPointWP\Utilities::var_dump_expandable(mixed args)
Do a var_dump, but within a container that can be expanded or contracted.
- Visibility: public
- This method is static.
- args mixed
array tp\TouchPointWP\Utilities::getAllHeaders()
Get all HTTP request headers.
- Visibility: public
- This method is static.
- array -
int tp\TouchPointWP\Utilities::updatePostImageFromUrl(int postId, string|null newUrl, string title, bool verbose)
Updates or removes a post's featured image from a URL (e.g. from TouchPoint).
If the $newUrl is blank or null, the image is removed.
- Visibility: public
- This method is static.
- postId int* newUrl string|null* title string* verbose bool
- int - The attachmentId for the image. Can be reused for other posts.
string tp\TouchPointWP\Utilities::standardizeHTags(int maxAllowed, string input)
- Visibility: public
- This method is static.
- maxAllowed int - 1 to 6, corresponding to h1 to h6.
- input string - The string within which headings should be standardized.
- string -
string tp\TouchPointWP\Utilities::standardizeHtml(?string html, ?string context)
- Visibility: public
- This method is static.
- html ?string - The HTML to be standardized.
- context ?string - A context string to pass to hooks.
- string -
void tp\TouchPointWP\Utilities::forceSlugUpdate(mixed postId, mixed newSlug)
Sometimes WordPress tries to be smarter than we want it to be.
THIS DOES NOT DO ANY KIND OF VALIDATION OR REPLACEMENT. It is assumed that the input is already completely ready to go and won't cause collisions.
- Visibility: public
- This method is static.
- postId mixed* newSlug mixed
string tp\TouchPointWP\Utilities::stringToSlug(string s)
Convert a string to something that's acceptable for use as a slug.
- Visibility: public
- This method is static.
- s string
- string -
?object tp\TouchPointWP\Utilities::checkForUpdate()
Returns true if a new release is available.
- Visibility: public
- This method is static.
- ?object -
mixed tp\TouchPointWP\Utilities::checkForUpdate_transient(mixed transient)
- Visibility: public
- This method is static.
- transient mixed
- mixed
mixed tp\TouchPointWP\Utilities::fileHeadersFromWeb(string url, array headers)
- Visibility: public
- This method is static.
- url string* headers array
- mixed
mixed tp\TouchPointWP\Utilities::fileHeadersFromString(string data, array headers)
- Visibility: public
- This method is static.
- data string* headers array
- mixed
mixed tp\TouchPointWP\Utilities::getClientIp()
- Visibility: public
- This method is static.
- mixed
bool tp\TouchPointWP\Utilities::validateRegistrantEmailAddress(?string nickname, ?string emailAddress, ?string resultComment)
Determine if an email address or user should be accepted as a new registrant. (e.g. informal auth)
- Visibility: public
- This method is static.
- nickname ?string* emailAddress ?string* resultComment ?string - If a spam provider provides a comment about why content was allowed or rejected, it goes here.
- bool - True if acceptable, false if not acceptable.
bool tp\TouchPointWP\Utilities::validateMessage(?string nickname, ?string emailAddress, ?string message, ?string resultComment)
Determine if an email address or user should be accepted as a new registrant. (e.g. informal auth)
- Visibility: public
- This method is static.
- nickname ?string* emailAddress ?string* message ?string* resultComment ?string - If a spam provider provides a comment about why content was allowed or rejected, it goes here.
- bool - True if acceptable, false if not acceptable.
Documentation generated November 19, 2025 1:15am.
- Simple RSVP
- People Lists
- Involvements
- Outreach Partners
- SQL & Python Reports
- Events Calendar from Meetings (Beta)
- Events Calendar Plugin Integration (Deprecated)
- tp
- tp\TouchPointWP
- Api
- Auth
- tp\TouchPointWP\Blocks
- CalendarGrid
- EventsCalendar
- ExtraValueHandler
- Geo
- tp\TouchPointWP\Interfaces
- Involvement
- Involvement_PostTypeSettings
- InvolvementMembership
- Location
- Meeting
- MeetingArray
- Partner
- Person
- PostTypeCapable
- RegistrationType
- Report
- Rsvp
- Settings
- Stats
- StatusWidget
- Taxonomies
- TouchPointWP
- TouchPointWP_AdminAPI
- TouchPointWP_Exception
- TouchPointWP_WPError
- Utilities
- tp\TouchPointWP