WOOF_Post

Extends WOOF_Wrap

Methods

Represents a single post or page in WordPress, including posts based on custom post types.

Example: Obtaining a WOOF_Post

List of Methods

Magic Methods

  • __call( String $name, Array $arguments )Mixed OR WOOF_Silent

    Implements PHP’s __call magic method to provide a number of clever handlers for the unknown method call.

  • __get( String $name )Mixed OR WOOF_Silent

    Implements PHP’s __get magic method to provide a number of clever handlers for the unknown method call.

  • __set( String $name, Mixed $value )

    Implements PHP’s __set magic method allowing properties of the post to be set via direct property assignment.

Property Methods

Manipulation

  • __set( String $name, Mixed $value )

    Implements PHP’s __set magic method allowing properties of the post to be set via direct property assignment.

  • add_term( Mixed $id, String $taxonomy = null )

    Links this post with a taxonomy term, via the WordPress function wp_set_object_terms.

  • assign( Array $args )

    Bulk assign a number of properties of this post at the one time.Note: this method does not update the database, you will need to call the method WOOF_Post::update after using this method.

  • delete()

    Deletes the post behind this object in the database, via the WordPress function wp_delete_post.

  • publish()

    Updates the status of this post to “publish”, via the WordPress function wp_publish_post.

  • remove_term( Mixed $id, String $taxonomy )

    Detaches the specified term from the given taxonomy from this post.

  • update( Boolean $strip = true )WOOF_Post

    Updates the database with any changes made to this post.

Theming

Posts

  • ancestors()WOOF_Collection of WOOF_Post

    Retrieves a collection of ancestors for this post from lowest to highest in the hierarchy.

  • children( Arguments $args = array() )WOOF_Collection of WOOF_Post

    Retrieves the immediate child objects of this post.This method uses get_posts to retrieve the children, and you can further clarify this query with the args parameter (the parent parameter will be enforced to actually retrieve the children).

  • delete()

    Deletes the post behind this object in the database, via the WordPress function wp_delete_post.

  • parent()WOOF_Post

    Retrieves the immediate parent object of this post.Note: this will only return meaningful results if the post is based on a hierarchical type.

  • publish()

    Updates the status of this post to “publish”, via the WordPress function wp_publish_post.

  • siblings( Boolean $include_this = false )WOOF_Collection of WOOF_Post

    Retrieves the sibling objects of this post, that is, objects that exist at the same level in the hierarchy as the current object.Note: this will only return results if the post is based on a hierarchical post type.

  • top()MEOW_Post

    Retrieves the top level ancestor of this post.Note: this will only return a meaningful result if this post is based on a hierarchical post type.

  • update( Boolean $strip = true )WOOF_Post

    Updates the database with any changes made to this post.

Attachments

Traversal

  • children( Arguments $args = array() )WOOF_Collection of WOOF_Post

    Retrieves the immediate child objects of this post.This method uses get_posts to retrieve the children, and you can further clarify this query with the args parameter (the parent parameter will be enforced to actually retrieve the children).

  • depth( Boolean $nocache = false )Integer

    Returns the depth of this post in the hierarchy, where 1 is the top level, 2 is the 2nd level, and so on.

  • has_children()WOOF_Collection of WOOF_Post OR Boolean

    Checks if this post has any children.Note: this will only return meaningful results if the current object is based on a hierarchical post type.

  • has_parent()WOOF_Post OR Boolean

    Checks if this post has a parent.Note: this will only return meaningful results if this post is based on an hierarchical post type.

  • next( Arguments $args = array() )WOOF_Post OR WOOF_Silent

    Gets the next post in the set of siblings for this post as defined by the query in the $args parameter.

  • parent()WOOF_Post

    Retrieves the immediate parent object of this post.Note: this will only return meaningful results if the post is based on a hierarchical type.

  • prev( Arguments $args = array() )WOOF_Post OR WOOF_Silent

    Gets the previous post in the set of siblings for this post as defined by the query in the $args parameter.

Comments

Taxonomy Terms

Users

Post Types

Templates

  • template()String

    Returns the file name of the current template, sans-extension, if a custom template is attached.Note: this function does not exhaustively cover the possibilities in the WordPress Template Hierarchy, it is currently used only in more specific cases in MasterPress.

Utility

  • rep( String $class, Array $arguments )Mixed OR WOOF_Silent

    Attempts to instantiate a class representing this post for the given class name and arguments, and if successful returns that class.

  • trim_excerpt( Arguments $args = "[...]" )String

    A utility function to apply the WordPress excerpt_length and excerpt_more filters to create an excerpt from a given string.Note: this method is used internally by the WOOF_Post::excerpt. .

Multi-Site

  • url_in_site()String

    Returns the root-relative URL of this field within its site in a multi-site environment.

Column Listings

  • col()WOOF_PostCol

    Returns a woof-postcol object to provide an API for the column expressions used in the “Columns” section of the Create / Edit Post Type screen in MasterPress. This is accessed through a “col” property in the expression, as shown below.

Internal Use

  • default_template()String

    An internal function to retrieve the default template file name in the WordPress template hierarchy for this post. .

  • trim_excerpt( Arguments $args = "[...]" )String

    A utility function to apply the WordPress excerpt_length and excerpt_more filters to create an excerpt from a given string.Note: this method is used internally by the WOOF_Post::excerpt. .

  • __call( String $name, Array $arguments )Mixed OR WOOF_Silent

    Implements PHP’s __call magic method to provide a number of clever handlers for the unknown method call.

  • __get( String $name )Mixed OR WOOF_Silent

    Implements PHP’s __get magic method to provide a number of clever handlers for the unknown method call.

  • __set( String $name, Mixed $value )

    Implements PHP’s __set magic method allowing properties of the post to be set via direct property assignment.

  • add_term( Mixed $id, String $taxonomy = null )

    Links this post with a taxonomy term, via the WordPress function wp_set_object_terms.

  • ancestors()WOOF_Collection of WOOF_Post

    Retrieves a collection of ancestors for this post from lowest to highest in the hierarchy.

  • assign( Array $args )

    Bulk assign a number of properties of this post at the one time.Note: this method does not update the database, you will need to call the method WOOF_Post::update after using this method.

  • attachments( Array / String $args = array() )WOOF_Collection of WOOF_Attachment

    Retrieves a collection of attachment objects for this post and matching the given query arguments.Note: The args parameter for this method is a preset for WordPress’ get_posts function that is forced to query for the attachment post_type.

  • author()WOOF_User

    Returns a WOOF_User object representing the author of this post.

  • categories()WOOF_Collection of WOOF_Term

    Returns a collection of WOOF_Term objects representing the categories attached to this post.

  • children( Arguments $args = array() )WOOF_Collection of WOOF_Post

    Retrieves the immediate child objects of this post.This method uses get_posts to retrieve the children, and you can further clarify this query with the args parameter (the parent parameter will be enforced to actually retrieve the children).

  • col()WOOF_PostCol

    Returns a woof-postcol object to provide an API for the column expressions used in the “Columns” section of the Create / Edit Post Type screen in MasterPress. This is accessed through a “col” property in the expression, as shown below.

  • comments( Arguments $args )WOOF_Collection of WOOF_Comment

    Retrieves a collection of WOOF_Comment objects representing the comments for this post.

  • comments_count()Integer

    Returns the integer count of comments for this post.This is simply an alternative syntax for WordPress’ get_comments_number function.

  • comments_number( String $zero = "", String $one = "", String $many = "" )String

    Returns a formatted string representing the count of comments for this post.Note: All format strings are run through sprintf with the current comment count.

  • comments_open()Boolean

    Checks if comments are open for this post.

  • comments_url( Boolean $root_relative = false )String

    Gets the comments URL for this post.

  • content( Arguments $args = array() )String

    Returns the content for this post, either filtered or not.

  • content_feed( String $feed_type = null )String

    Retrieves the post content as appropriate for a syndicated feed, by applying the appropriate WordPress filters to the raw content recorded.

  • date( String $format = null )String OR Integer

    Gets the publish date of this post.

  • default_template()String

    An internal function to retrieve the default template file name in the WordPress template hierarchy for this post. .

  • delete()

    Deletes the post behind this object in the database, via the WordPress function wp_delete_post.

  • depth( Boolean $nocache = false )Integer

    Returns the depth of this post in the hierarchy, where 1 is the top level, 2 is the 2nd level, and so on.

  • edit_url( Arguments $args = array() )String

    Retrieves the URL for editing this post in WordPress.Note: this method does not check if the current user is allowed to edit the post, so use with care (WordPress will intercept any attempts to edit something that’s now allowed, but it leads to a bad user experience at worst).

  • excerpt( Arguments $args = array() )String

    Generate an excerpt for this post, or get the manual excerpt, depending on the args provided.

  • has_category( String $slug )WOOF_Term OR Boolean

    Checks if this post has the specified category slug attached.

  • has_children()WOOF_Collection of WOOF_Post OR Boolean

    Checks if this post has any children.Note: this will only return meaningful results if the current object is based on a hierarchical post type.

  • has_parent()WOOF_Post OR Boolean

    Checks if this post has a parent.Note: this will only return meaningful results if this post is based on an hierarchical post type.

  • has_status( Array / String $status )Boolean

    Checks if this post has a status matching one or more given statuses.

  • has_tag( String $slug )WOOF_Term OR Boolean

    Checks if this post has the specified post tag slug attached.

  • has_term( String $slug, String $taxonomy = "category" )WOOF_Term OR Boolean

    Checks if this post has the specified slug from a given taxonomy attached to it.Note: this currently only works for taxonomy terms attached via the built-in WordPress UI, it does not regard any values set in “Related Term” field types in MasterPress (this may change in future releases). .

  • has_thumbnail()Boolean

    An alias for the WOOF_Post::has_featured_image method, to check if this post has a Featured Image (which is also referred to as a post thumbnail in WordPress).

  • hierarchical()Boolean

    Checks if the type of the current post is hierarchical.

  • id()Integer

    Returns the database ID of this post.

  • image_attachments( Array / String $args = array() )WOOF_Collection of WOOF_Attachment

    Retrieves a collection of WOOF_Attachment objects representing the image attachments for this post.Note: The args parameter for this method is a preset for WordPress’ get_posts function that is forced to query for the attachment post_type.

  • in_trash()Boolean

    Checks if this post is currently in the trash.

  • is( Mixed $post, String $type )Boolean

    Checks to see if this post is the same as another post.

  • is_a( String $type )Boolean

    Checks if this post has the given post type.

  • is_an( String $type )Boolean

    An alias for the WOOF_Post::is_a method, to checks if this post has the given post type.

  • is_child_of( Mixed $post )Boolean

    Checks to see if this post is a child of another post (at any level in the hierarchy).

  • is_current()Boolean

    Checks if this post is the current active post being displayed.

  • is_tagged( String $slug )WOOF_Term OR Boolean

    An alias for the WOOF_Post::has_tag method to check if this post has the specified post tag slug attached.

  • menu_edit_url()String

    Returns the editing URL for this page, appropriate for a call to the add_menu_page or add_submenu_page WordPress functions.

  • menu_order( Integer $base = 0 )Integer

    Retrieves the menu order of this post (the index in the user defined order), with the ability to tweak the base value.

  • meta( String $meta_key, $single = false )String OR WOOF_SimpleCollection of String

    Retrieves the value or a collection of values for the given meta_key.

  • modified( String $format = null )String OR Integer

    Gets the modified date of this post.

  • next( Arguments $args = array() )WOOF_Post OR WOOF_Silent

    Gets the next post in the set of siblings for this post as defined by the query in the $args parameter.

  • parent()WOOF_Post

    Retrieves the immediate parent object of this post.Note: this will only return meaningful results if the post is based on a hierarchical type.

  • post_type()WOOF_PostType

    Retrieves a WOOF_PostType object repesenting the post type of this post, whether this is a custom post type or built-in.

  • prev( Arguments $args = array() )WOOF_Post OR WOOF_Silent

    Gets the previous post in the set of siblings for this post as defined by the query in the $args parameter.

  • publish()

    Updates the status of this post to “publish”, via the WordPress function wp_publish_post.

  • raw_content()String

    Retrieves the raw unfiltered content for the post.

  • remove_term( Mixed $id, String $taxonomy )

    Detaches the specified term from the given taxonomy from this post.

  • rep( String $class, Array $arguments )Mixed OR WOOF_Silent

    Attempts to instantiate a class representing this post for the given class name and arguments, and if successful returns that class.

  • siblings( Boolean $include_this = false )WOOF_Collection of WOOF_Post

    Retrieves the sibling objects of this post, that is, objects that exist at the same level in the hierarchy as the current object.Note: this will only return results if the post is based on a hierarchical post type.

  • slug()String

    Retrieves the slug for the current post.

  • tagged( String $slug )WOOF_Term OR Boolean

    An alias for the WOOF_Post::has_tag method to check if this post has the specified post tag slug attached.

  • tags()WOOF_Collection of WOOF_Term

    Returns a collection of WOOF_Term objects representing the tags attached to this post.

  • template()String

    Returns the file name of the current template, sans-extension, if a custom template is attached.Note: this function does not exhaustively cover the possibilities in the WordPress Template Hierarchy, it is currently used only in more specific cases in MasterPress.

  • terms( String $taxonomy )WOOF_Collection of

    Retrieves a collection of WOOF_Term objects representing the terms attached to this post for the given taxonomy.

  • thumbnail()WOOF_Image OR WOOF_Silent

    An alias for the WOOF_Post::featured_image method, to retrieve a WOOF_Image object representing the featured image (which is also referred to as a post thumbnail in WordPress), if available.

  • title()String

    Returns the title of this post.

  • title_rss()String

    Retrieves the title of the post, with the the_title_rss filter applied.

  • top()MEOW_Post

    Retrieves the top level ancestor of this post.Note: this will only return a meaningful result if this post is based on a hierarchical post type.

  • trim_excerpt( Arguments $args = "[...]" )String

    A utility function to apply the WordPress excerpt_length and excerpt_more filters to create an excerpt from a given string.Note: this method is used internally by the WOOF_Post::excerpt. .

  • type()WOOF_PostType

    Retrieves a WOOF_PostType object repesenting the post type of this post, whether this is a custom post type or built-in.

  • type_name()String

    Retrieves the name of the post type for the current post.

  • update( Boolean $strip = true )WOOF_Post

    Updates the database with any changes made to this post.

  • url( Boolean $root_relative = true )String

    Gets a URL for this post, which is root relative by default (excludes the domain and protocol).

  • url_in_site()String

    Returns the root-relative URL of this field within its site in a multi-site environment.

  • urlencode( Boolean $root_relative = true )String

    Gets a url encoded URL for this post, which is root relative by default (excludes the domain and protocol), which can be used inside other URLs.

Base Class Methods

View method list from the base class WOOF_Wrap.

Latest From the Blog

MasterPress 1.3.10 is now available

9th November 2023

MasterPress 1.3.10 is a feature and bugfix release. Workaround for fatal error introduced by changes to WordPress’ wpdb class in WordPress 6.4. Added actions to MPC files upload_field & WF image save_image functions.

Plugin Requirements

MasterPress requires a minimum of WordPress version 4.9, MySQL 5.6, and PHP version 5.6.20.

We also recommend that PHP is configured to use a memory limit of 64MB per request (128MB may be required for sites with higher complexity).

This plug-in is not compatible with the WordPress.com hosted service.

Three AM