tp TouchPointWP PostTypeCapable - TenthPres/TouchPoint-WP GitHub Wiki
tp\TouchPointWP\PostTypeCapable
This is a base class for those objects that can be derived from a Post.
- Full name:
\tp\TouchPointWP\PostTypeCapable - This class implements:
\tp\TouchPointWP\Interfaces\module,\tp\TouchPointWP\Interfaces\storedAsPost,\tp\TouchPointWP\Interfaces\actionButtons - This class is an Abstract class
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.