tp TouchPointWP TouchPointWP - TenthPres/TouchPoint-WP GitHub Wiki
tp\TouchPointWP\TouchPointWP
Main plugin class.
- Class name: TouchPointWP
- Namespace: \tp\TouchPointWP
Constants
VERSION
const VERSION = "0.0.95"
TOKEN
const TOKEN = "TouchPointWP"
API_ENDPOINT
const API_ENDPOINT = "touchpoint-api"
API_ENDPOINT_APP_EVENTS
const API_ENDPOINT_APP_EVENTS = "app-events"
API_ENDPOINT_INVOLVEMENT
const API_ENDPOINT_INVOLVEMENT = "inv"
API_ENDPOINT_GLOBAL
const API_ENDPOINT_GLOBAL = "global"
API_ENDPOINT_PERSON
const API_ENDPOINT_PERSON = "person"
API_ENDPOINT_MEETING
const API_ENDPOINT_MEETING = "mtg"
API_ENDPOINT_ADMIN
const API_ENDPOINT_ADMIN = "admin"
API_ENDPOINT_STATS
const API_ENDPOINT_STATS = "stats"
API_ENDPOINT_AUTH
const API_ENDPOINT_AUTH = "auth"
API_ENDPOINT_REPORT
const API_ENDPOINT_REPORT = "report"
API_ENDPOINT_ADMIN_SCRIPTZIP
const API_ENDPOINT_ADMIN_SCRIPTZIP = "admin/scriptzip"
API_ENDPOINT_CLEANUP
const API_ENDPOINT_CLEANUP = "cleanup"
API_ENDPOINT_GEOLOCATE
const API_ENDPOINT_GEOLOCATE = "geolocate"
SHORTCODE_PREFIX
const SHORTCODE_PREFIX = "TP-"
HOOK_PREFIX
const HOOK_PREFIX = "tp_"
INIT_ACTION_HOOK
const INIT_ACTION_HOOK = "tp_init"
SETTINGS_PREFIX
const SETTINGS_PREFIX = "tp_"
TABLE_PREFIX
const TABLE_PREFIX = "tp_"
TABLE_IP_GEO
const TABLE_IP_GEO = self::TABLE_PREFIX . "ipGeo"
TABLE_STATS
const TABLE_STATS = self::TABLE_PREFIX . "stats"
CACHE_TTL
const CACHE_TTL = 8
TTL_IP_GEO
const TTL_IP_GEO = 5
CACHE_PUBLIC
const CACHE_PUBLIC = 0
CACHE_PRIVATE
const CACHE_PRIVATE = 10
CACHE_NONE
const CACHE_NONE = 20
INVOLVEMENT_META_KEY
const INVOLVEMENT_META_KEY = \tp\TouchPointWP\TouchPointWP::SETTINGS_PREFIX . "invId"
MAX_API_CALLS
const MAX_API_CALLS = 20
Properties
joiner
public joiner = " ◦ "
- Visibility: public
settings
public mixed settings = null
Settings object
- Visibility: public
file
public mixed file
The main plugin file.
- Visibility: public
dir
public mixed dir
The main plugin directory.
- Visibility: public
assets_dir
public mixed assets_dir
The plugin assets directory.
- Visibility: public
assets_url
public mixed assets_url
The plugin assets URL, with trailing slash.
- Visibility: public
script_ext
public mixed script_ext
Suffix for JavaScripts.
- Visibility: public
debug
public mixed debug
- Visibility: public
Methods
isApi
bool tp\TouchPointWP\TouchPointWP::isApi()
Indicates that the current request is being processed through the API.
- Visibility: public
- This method is static.
Returns
- bool -
cronAdd15Minutes
mixed tp\TouchPointWP\TouchPointWP::cronAdd15Minutes(mixed schedules)
- Visibility: public
- This method is static.
Arguments
- schedules mixed
Returns
- mixed -
capitalPyScript
string tp\TouchPointWP\TouchPointWP::capitalPyScript(string|mixed text)
Find and replace links to /pyscript with their more functional brother, /PyScript. That small typo makes bad things happen.
- Visibility: public
- This method is static.
Arguments
- text string|mixed - The text to be modified. (should be a string, but this is WordPress, so maybe not.)
Returns
- string - The modified text.
admin
mixed tp\TouchPointWP\TouchPointWP::admin()
- Visibility: public
Returns
- mixed
scheduleCleanup
mixed tp\TouchPointWP\TouchPointWP::scheduleCleanup()
- Visibility: public
- This method is static.
Returns
- mixed
setCaching
mixed tp\TouchPointWP\TouchPointWP::setCaching(int level)
- Visibility: public
- This method is static.
Arguments
- level int
Returns
- mixed
doCacheHeaders
mixed tp\TouchPointWP\TouchPointWP::doCacheHeaders(int cacheLevel)
Spit out headers that prevent caching. Useful for API calls.
- Visibility: public
- This method is static.
Arguments
- cacheLevel int
Returns
- mixed
postHeadersAndFiltering
mixed tp\TouchPointWP\TouchPointWP::postHeadersAndFiltering()
- Visibility: public
- This method is static.
Returns
- mixed
TouchPointIcon
string tp\TouchPointWP\TouchPointWP::TouchPointIcon()
Get TouchPoint icon as an SVG that can printed inline.
- Visibility: public
- This method is static.
Returns
- string -
parseRequest
bool tp\TouchPointWP\TouchPointWP::parseRequest(bool continue, \WP wp, array|string extraVars)
- Visibility: public
Arguments
- continue bool - Whether to parse the request
- wp WP - Current WordPress environment instance
- extraVars array|string - Passed query variables
Returns
- bool - Whether other request parsing functions should be allowed to function.
currentUserIsAdmin
bool tp\TouchPointWP\TouchPointWP::currentUserIsAdmin()
Whether the current user is an admin.
- Visibility: public
- This method is static.
Returns
- bool -
printDynamicFooterScripts
void tp\TouchPointWP\TouchPointWP::printDynamicFooterScripts()
Print Dynamic Instantiation scripts.
- Visibility: public
adminPrintStyleOverrides
void tp\TouchPointWP\TouchPointWP::adminPrintStyleOverrides()
Force some styling overrides into admin views.
- Visibility: public
getJsLocalizationDir
string tp\TouchPointWP\TouchPointWP::getJsLocalizationDir()
- Visibility: public
Returns
- string -
loadLocalizations
mixed tp\TouchPointWP\TouchPointWP::loadLocalizations()
Load plugin textdomain
- Visibility: public
Returns
- mixed
isTenth
mixed tp\TouchPointWP\TouchPointWP::isTenth()
- Visibility: public
- This method is static.
Returns
- mixed
migrate
mixed tp\TouchPointWP\TouchPointWP::migrate(mixed force)
Compare the version numbers to determine if a migration is needed.
- Visibility: public
Arguments
- force mixed
Returns
- mixed
load
\tp\TouchPointWP\TouchPointWP tp\TouchPointWP\TouchPointWP::load(mixed file)
Load the settings, connect the references, and check that there aren't pending migrations.
- Visibility: public
- This method is static.
Arguments
- file mixed
Returns
- \tp\TouchPointWP\TouchPointWP -
init
void tp\TouchPointWP\TouchPointWP::init()
Initialize the plugin.
- Visibility: public
- This method is static.
renderBaseInlineScript
void tp\TouchPointWP\TouchPointWP::renderBaseInlineScript()
Prints the inline 'base' script. This is meant to be called in the wp_head and admin_head, and should only be called once on a page, but that is not automatically validated.
- Visibility: public
- This method is static.
registerScriptsAndStyles
mixed tp\TouchPointWP\TouchPointWP::registerScriptsAndStyles()
- Visibility: public
Returns
- mixed
requireScript
mixed tp\TouchPointWP\TouchPointWP::requireScript(?string name)
Enqueue TouchPoint Scripts. Also, always adds Base if it hasn't been added yet.
- Visibility: public
- This method is static.
Arguments
- name ?string
Returns
- mixed
requireStyle
mixed tp\TouchPointWP\TouchPointWP::requireStyle(?string name)
Enqueue TouchPoint Styles.
- Visibility: public
- This method is static.
Arguments
- name ?string
Returns
- mixed
filterByTag
string tp\TouchPointWP\TouchPointWP::filterByTag(?string tag, ?string handle)
Adds async/defer attributes to enqueued / registered scripts. If -defer or -async is present in the script's handle, the respective attribute is added.
DOES apply to ALL scripts, not just those in the template.
- Visibility: public
Arguments
- tag ?string - The script tag.
- handle ?string - The script handle.
Returns
- string - The HTML string.
ajaxGeolocate
mixed tp\TouchPointWP\TouchPointWP::ajaxGeolocate()
- Visibility: public
Returns
- mixed
geolocate
\tp\TouchPointWP\Geo|false tp\TouchPointWP\TouchPointWP::geolocate(bool useApi, bool includeRaw)
- Visibility: public
Arguments
- useApi bool - Set false to only use cached data, and not the IP API.
- includeRaw bool
Returns
- \tp\TouchPointWP\Geo|false - An object with 'lat', 'lng', and 'human' attributes, if a location could be identified. Or, false if not available.
reverseGeocode
\tp\TouchPointWP\Geo|false tp\TouchPointWP\TouchPointWP::reverseGeocode(float lat, float lng, bool includeIpLoc)
Get Reverse Geocode information based on a provided lat/lng.
- Visibility: public
Arguments
- lat float - Latitude
- lng float - Longitude
- includeIpLoc bool - Whether to use IP geolocation as a fallback data source.
Returns
- \tp\TouchPointWP\Geo|false - An object with a 'human' attribute, if a location could be identified. Or, false if not available.
getDivisionTermIdByDivId
int|false tp\TouchPointWP\TouchPointWP::getDivisionTermIdByDivId(int divId)
- Visibility: public
- This method is static.
Arguments
- divId int
Returns
- int|false - Returns the term ID number or false (or 0) if the division is not found, or not enabled.
instance
\tp\TouchPointWP\TouchPointWP tp\TouchPointWP\TouchPointWP::instance(mixed file)
Main TouchPointWP Instance
Ensures only one instance of TouchPointWP is loaded or can be loaded.
- Visibility: public
- This method is static.
Arguments
- file mixed
Returns
- \tp\TouchPointWP\TouchPointWP - instance
__clone
mixed tp\TouchPointWP\TouchPointWP::__clone()
Don't clone.
- Visibility: public
Returns
- mixed
__wakeup
mixed tp\TouchPointWP\TouchPointWP::__wakeup()
Don't deserialize.
- Visibility: public
Returns
- mixed
activation
mixed tp\TouchPointWP\TouchPointWP::activation()
Activation. Runs on activation.
- Visibility: public
Returns
- mixed
deactivation
mixed tp\TouchPointWP\TouchPointWP::deactivation()
Deactivation. Runs on deactivation.
- Visibility: public
Returns
- mixed
uninstall
mixed tp\TouchPointWP\TouchPointWP::uninstall()
Runs on uninstallation.
- Visibility: public
- This method is static.
Returns
- mixed
useTribeCalendarPro
bool tp\TouchPointWP\TouchPointWP::useTribeCalendarPro()
Indicates that Tribe Calendar Pro is enabled.
- Visibility: public
- This method is static.
Returns
- bool -
useTribeCalendar
bool tp\TouchPointWP\TouchPointWP::useTribeCalendar()
Indicates that Tribe Calendar is enabled.
- Visibility: public
- This method is static.
Returns
- bool -
useTribeOrMeetingCalendars
bool tp\TouchPointWP\TouchPointWP::useTribeOrMeetingCalendars()
Indicates that a calendar function is available, especially for the 2.0 mobile app option.
- Visibility: public
- This method is static.
Returns
- bool -
orderHierarchicalTerms
\WP_Term[] tp\TouchPointWP\TouchPointWP::orderHierarchicalTerms(\WP_Term[] terms, bool noChildlessParents)
Sort a list of hierarchical terms into a list in which each parent is immediately followed by its children.
- Visibility: public
- This method is static.
Arguments
- terms WP_Term[]* noChildlessParents bool
Returns
- \WP_Term[] -
host
?string tp\TouchPointWP\TouchPointWP::host()
- Visibility: public
Returns
- ?string - The URL of the TouchPoint instance. Null if not set.
getMemberTypesForDivisions
array tp\TouchPointWP\TouchPointWP::getMemberTypesForDivisions(string[] divisions)
Get the member types currently in use for the named divisions.
- Visibility: public
Arguments
- divisions string[]
Returns
- array -
getDivisionsAsKVArray
string[] tp\TouchPointWP\TouchPointWP::getDivisionsAsKVArray()
Format the list of divisions into an array with form-name-friendly IDs as the key.
- Visibility: public
Returns
- string[] -
getDivisions
mixed tp\TouchPointWP\TouchPointWP::getDivisions()
Returns an array of objects that correspond to divisions. Each Division has a name and an id. The name is both the Program and Division.
- Visibility: public
Returns
- mixed
getResCodes
mixed tp\TouchPointWP\TouchPointWP::getResCodes()
Returns an array of objects that correspond to resident codes. Each ResCode has a name, a code, and an id.
- Visibility: public
Returns
- mixed
getCampuses
mixed tp\TouchPointWP\TouchPointWP::getCampuses()
Returns an array of objects that correspond to campuses. Each Campus has a name, a code, and an id.
- Visibility: public
Returns
- mixed
getGenders
mixed tp\TouchPointWP\TouchPointWP::getGenders()
Returns an array of objects that correspond to the genders. Each Gender has a name and an id.
- Visibility: public
Returns
- mixed
getKeywords
mixed tp\TouchPointWP\TouchPointWP::getKeywords()
Returns an array of objects that correspond to keywords. Each Keyword has a name and an id.
- Visibility: public
Returns
- mixed
getKeywordsAsKVArray
string[] tp\TouchPointWP\TouchPointWP::getKeywordsAsKVArray()
Format the list of divisions into an array with form-name-friendly IDs as the key.
- Visibility: public
Returns
- string[] -
getPersonEvFields
array tp\TouchPointWP\TouchPointWP::getPersonEvFields(array|null matches)
Returns an array of objects that correspond to Person Extra Value Fields. Each has a name and a type.
- Visibility: public
Arguments
- matches array|null - Provide an array of items that should be matched. If provided, only matches are returned.
Returns
- array -
getPersonEvFieldsAsKVArray
string[] tp\TouchPointWP\TouchPointWP::getPersonEvFieldsAsKVArray(string|null type, bool addNone)
Format the list of Person Extra Value Fields into an array with form-name-friendly IDs as the key.
- Visibility: public
Arguments
- type string|null - To limit the list to a particular data type, provide the name of the datatype. Needs to match the type in TouchPoint.
- addNone bool - Set true to add a "none" option to the list.
Returns
- string[] -
getFamilyEvFields
array tp\TouchPointWP\TouchPointWP::getFamilyEvFields(array|null matches)
Returns an array of objects that correspond to Family Extra Value Fields. Each has a name and a type.
- Visibility: public
Arguments
- matches array|null - Provide an array of items that should be matched. If provided, only matches are returned.
Returns
- array -
getFamilyEvFieldsAsKVArray
string[] tp\TouchPointWP\TouchPointWP::getFamilyEvFieldsAsKVArray(string|null type, bool addNone)
Format the list of Family Extra Value Fields into an array with form-name-friendly IDs as the key.
- Visibility: public
Arguments
- type string|null - To limit the list to a particular data type, provide the name of the datatype. Needs to match the type in TouchPoint.
- addNone bool - Set true to add a "none" option to the list.
Returns
- string[] -
currentUserPerson
\tp\TouchPointWP\Person|null tp\TouchPointWP\TouchPointWP::currentUserPerson()
Get the person that corresponds to the current user, if the current user is authenticated, and the user is associated with a PeopleId.
- Visibility: public
- This method is static.
Returns
- \tp\TouchPointWP\Person|null -
getSavedSearches
string[][] tp\TouchPointWP\TouchPointWP::getSavedSearches(?int peopleId, mixed includeValue)
Get a list of saved searches pertinent to the current user. These are grouped by type: User's searches, Public, and Flags.
Because these are user-specific and relatively volatile, they are NOT cached in WordPress.
- Visibility: public
Arguments
- peopleId ?int* includeValue mixed
Returns
- string[][] -
flattenArrayToKV
array tp\TouchPointWP\TouchPointWP::flattenArrayToKV(array array, string kField, string vField, string kPrefix)
- Visibility: public
- This method is static.
Arguments
- array array* kField string* vField string* kPrefix string
Returns
- array -
updatePersonEvFields
false|object tp\TouchPointWP\TouchPointWP::updatePersonEvFields()
Update the Person Extra Values if they're stale.
- Visibility: public
Returns
- false|object - False on failure
updateFamilyEvFields
false|object tp\TouchPointWP\TouchPointWP::updateFamilyEvFields()
Update the Person Extra Values if they're stale.
- Visibility: public
Returns
- false|object - False on failure.
apiGet
\stdClass|array tp\TouchPointWP\TouchPointWP::apiGet(string command, ?array parameters, int timeout, mixed verbose)
- Visibility: public
Arguments
- command string - The thing to get
- parameters ?array - URL parameters to be added.
- timeout int - Amount of time in sec to wait before timing out.
- verbose mixed
Returns
- \stdClass|array - An array with headers, body, and other keys Data is generally in json_decode($response['body'])->data
apiPost
\stdClass|array tp\TouchPointWP\TouchPointWP::apiPost(string command, ?mixed data, int timeout)
- Visibility: public
Arguments
- command string - The thing to post
- data ?mixed - Data to post
- timeout int - Amount of time in sec to wait before timing out.
Returns
- \stdClass|array - An object that corresponds to the Data python object in TouchPoint.
extGet
array tp\TouchPointWP\TouchPointWP::extGet(string url, ?array parameters)
- Visibility: public
Arguments
- url string - The destination of the request.
- parameters ?array - URL parameters to be added.
Returns
- array - An array with headers, body, and other keys.
doPersonQuery
\stdClass tp\TouchPointWP\TouchPointWP::doPersonQuery(array q, bool verbose, int timeout)
Submit a person query to TouchPoint with a structured array with the parameters.
- Visibility: public
Arguments
- q array* verbose bool* timeout int
Returns
- \stdClass - The people objects are contained within ->people.
queueUpdateDeployedScripts
mixed tp\TouchPointWP\TouchPointWP::queueUpdateDeployedScripts()
Cause a script update on next load.
- Visibility: public
- This method is static.
Returns
- mixed
updateDeployedScripts
void tp\TouchPointWP\TouchPointWP::updateDeployedScripts(bool force)
- Visibility: public
Arguments
- force bool
queueFlushRewriteRules
mixed tp\TouchPointWP\TouchPointWP::queueFlushRewriteRules()
Cause a flushing of rewrite rules on next load.
- Visibility: public
- This method is static.
Returns
- mixed
flushRewriteRules
mixed tp\TouchPointWP\TouchPointWP::flushRewriteRules(bool force)
Execute a flushing of the rewrite rules, if either absolutely necessary ($force = true) or enqueued by queuing function.
- Visibility: public
Arguments
- force bool
Returns
- mixed
enqueuePartialsStyle
mixed tp\TouchPointWP\TouchPointWP::enqueuePartialsStyle()
This function enqueues the stylesheet for the default templates, to avoid registering the style on sites where custom templates exist.
- Visibility: public
- This method is static.
Returns
- mixed
enqueueActionsStyle
mixed tp\TouchPointWP\TouchPointWP::enqueueActionsStyle(string action)
This function enqueues the stylesheet for actions (swal, basically).
- Visibility: public
- This method is static.
Arguments
- action string - This string identifies which action is being used. This should be passed to the filter so the filter can make an informed decision about whether to exclude the stylesheet.
Returns
- mixed
newQueryObject
array tp\TouchPointWP\TouchPointWP::newQueryObject()
Create a basic parameter array for doPersonQuery
- Visibility: public
- This method is static.
Returns
- array -
validateThatTpWpUserExists
mixed tp\TouchPointWP\TouchPointWP::validateThatTpWpUserExists()
- Visibility: public
Returns
- mixed
setTpWpUserAsCurrent
void tp\TouchPointWP\TouchPointWP::setTpWpUserAsCurrent()
Make the TPWP user the active one, so permissions are not dependent on whoever happens to be running things at the moment.
- Visibility: public
unsetTpWpUserAsCurrent
void tp\TouchPointWP\TouchPointWP::unsetTpWpUserAsCurrent()
Restore the actual user to the user position.
- Visibility: public