filename(); } /** * Register a new template object. * * @since 3.0.0 * @access public * @param string $filename * @param array $args * @return void */ public function __construct( $filename, array $args = [] ) { foreach ( array_keys( get_object_vars( $this ) ) as $key ) { if ( isset( $args[ $key ] ) ) { $this->$key = $args[ $key ]; } } // Allow `post_types` as an alias for `subtype`. if ( isset( $args['post_types'] ) ) { $this->subtype = (array) $args['post_types']; } $this->filename = $filename; } /** * Returns the filename relative to the templates location. * * @since 3.0.0 * @access public * @return string */ public function filename() { return $this->filename; } /** * Returns the internationalized text label for the template. * * @since 3.0.0 * @access public * @return string */ public function label() { return $this->label; } /** * Conditional function to check what type of template this is. * * @since 3.0.0 * @access public * @return bool */ public function isType( $type ) { return $type === $this->type; } /** * Conditional function to check if the template has a specific subtype. * * @since 3.0.0 * @access public * @return bool */ public function hasSubtype( $subtype ) { return ! $this->subtype || in_array( $subtype, (array) $this->subtype ); } /** * Conditional function to check if the template is for a post type. * * @since 3.0.0 * @access public * @return bool */ public function forPostType( $type ) { return $this->isType( 'post' ) && $this->hasSubtype( $type ); } }