MEOW_Field

Extends WOOF_Collection

Delegate MPFT

Methods

Represents a single field within a MasterPress field set. 

This class implements many of PHP 5’s magic methods to provide a number of benefits:

  • Fields can be echoed directly to allow for very readable and intuitive template code.
  • A dynamic API off the field object based upon the type of field that you have setup in MasterPress. This is achieved by delegating calls to a type delegate object that can handle the call. All type delegate objects are subclasses of the MPFT (MasterPress Field Type) class.
  • Type delegates can implement methods appropriate for the Iterator, ArrayAccess, and Countable interfaces so that the field can be directly iterated over, accessed like an array, or simply counted via PHP’s count function.   

Example: Obtaining a MEOW_Field

List of Methods

Magic Methods

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

    An implementation of PHP 5’s __call magic method, to allow field objects to call unknown methods directly.

  • __get()Mixed

    An implementation of PHP 5’s __get magic method, to allow field objects to access unknown properties directly.

  • __set( String $name, Mixed $value )

    An implementation of PHP 5’s __set magic method, to allow unknown field properties to be set directly.

  • __toString()String

    An implementation of PHP 5’s __toString magic method, to allow this field to be echoed directly.

Property Methods

  • blank()Boolean

    Checks if the field is empty or non-existent.

  • count()Integer

    This method’s behaviour depends on the type of field you’re dealing with.

  • exists()Boolean

    Check that this field does indeed exist, in the sense that it is a defined field against the set or object it is requested from.

  • fb( String $default )String

    A shorthand synonym for the fallback method.

  • field_name()String

    Returns the name of this field.

  • field_set()MEOW_FieldSet

    Retrieves the MEOW_FieldSet object that contains this field.

  • is_empty()Boolean

    A synonym for the blank method to check if the value of this field is empty (not specified).

  • set_index()Integer

    Retrieve the current set index for this field.

  • val( $value = null )Mixed

    A shorthand synonym for the value method, to retrieve the value of the field.

  • value( $ )Mixed

    Returns the value of the field, as determined by the field type.Important: the _toString PHP magic method handles direct echoing of field values out to your templates by simply echoing the a MEOW_Field object directly, but this automatic conversion to a string does NOT happen when using the value of a field as a variable in an expression.

Manipulation

  • __set( String $name, Mixed $value )

    An implementation of PHP 5’s __set magic method, to allow unknown field properties to be set directly.

  • set_value( Mixed $value )Mixed

    Sets the value of the field.

  • update()

    Updates the database with with any changes made by any methods that can update the field, which are: val, value, prop, __set.

  • val( $value = null )Mixed

    A shorthand synonym for the value method, to retrieve the value of the field.

Theming

  • fallback( String $default )String

    Returns a supplied fallback value if this field is blank or does not exist.

  • or_else( String $default )String

    Returns a supplied fallback value if this field is blank or does not exist.

  • prop( String $name = null, String $value (optional) = null )String OR Array

    Either get or set a named property associated with this field type, or retrieve an associative array of all properties and values if the $name argument is not provided.

  • raw()Mixed

    Retrieve the raw unprocessed value of the field.

Utility

  • dump_data()String

    Output the raw data contained in this field, for debugging purposes.

  • is_editable()Boolean

    Checks whether or not this field is editable for the current user, based on the current user’s capabilities.

Internal Use

  • data()Array

    Gets an associative array of raw data contained in this field.

  • field_set_collection()MEOW_FieldSetCollection

    Retrieves the MEOW_FieldSetCollection object that contains this field.

  • info()MPM_Field

    Returns a model object containing information about the definition of this field.

  • is_editable()Boolean

    Checks whether or not this field is editable for the current user, based on the current user’s capabilities.

  • iterator_items()Array

    A function used internally to allow this field to be directly iterated over by forwarding the call on to the field type delegate object.

  • mark_dirty()

    An internal function used to mark this field as dirty (updated in some way).

  • object()WOOF_Wrap

    Retrieves the WordPress object associated with this field, whether this is a post, (taxonomy) term, user, or a site.

  • offsetExists( Mixed $offset )Boolean

    An implementation of the offsetExists method in PHP’s ArrayAccess interface.

  • offsetGet( Mixed $offset )Mixed

    An implementation of the offsetGet method in PHP’s ArrayAccess interface.

  • prop_val( String $name )String

    Get the raw value of a field type property. A property in this case is not a standard PHP object property, but rather a meta property that further clarifies the value of this field.

  • prop_value( String $name )String

    Get the raw value of a field type property. A property in this case is not a standard PHP object property, but rather a meta property that further clarifies the value of this field.

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

    An implementation of PHP 5’s __call magic method, to allow field objects to call unknown methods directly.

  • __get()Mixed

    An implementation of PHP 5’s __get magic method, to allow field objects to access unknown properties directly.

  • __set( String $name, Mixed $value )

    An implementation of PHP 5’s __set magic method, to allow unknown field properties to be set directly.

  • __toString()String

    An implementation of PHP 5’s __toString magic method, to allow this field to be echoed directly.

  • blank()Boolean

    Checks if the field is empty or non-existent.

  • count()Integer

    This method’s behaviour depends on the type of field you’re dealing with.

  • data()Array

    Gets an associative array of raw data contained in this field.

  • dump_data()String

    Output the raw data contained in this field, for debugging purposes.

  • exists()Boolean

    Check that this field does indeed exist, in the sense that it is a defined field against the set or object it is requested from.

  • fallback( String $default )String

    Returns a supplied fallback value if this field is blank or does not exist.

  • fb( String $default )String

    A shorthand synonym for the fallback method.

  • field_name()String

    Returns the name of this field.

  • field_set()MEOW_FieldSet

    Retrieves the MEOW_FieldSet object that contains this field.

  • field_set_collection()MEOW_FieldSetCollection

    Retrieves the MEOW_FieldSetCollection object that contains this field.

  • info()MPM_Field

    Returns a model object containing information about the definition of this field.

  • is_editable()Boolean

    Checks whether or not this field is editable for the current user, based on the current user’s capabilities.

  • is_empty()Boolean

    A synonym for the blank method to check if the value of this field is empty (not specified).

  • iterator_items()Array

    A function used internally to allow this field to be directly iterated over by forwarding the call on to the field type delegate object.

  • mark_dirty()

    An internal function used to mark this field as dirty (updated in some way).

  • object()WOOF_Wrap

    Retrieves the WordPress object associated with this field, whether this is a post, (taxonomy) term, user, or a site.

  • offsetExists( Mixed $offset )Boolean

    An implementation of the offsetExists method in PHP’s ArrayAccess interface.

  • offsetGet( Mixed $offset )Mixed

    An implementation of the offsetGet method in PHP’s ArrayAccess interface.

  • or_else( String $default )String

    Returns a supplied fallback value if this field is blank or does not exist.

  • prop( String $name = null, String $value (optional) = null )String OR Array

    Either get or set a named property associated with this field type, or retrieve an associative array of all properties and values if the $name argument is not provided.

  • prop_val( String $name )String

    Get the raw value of a field type property. A property in this case is not a standard PHP object property, but rather a meta property that further clarifies the value of this field.

  • prop_value( String $name )String

    Get the raw value of a field type property. A property in this case is not a standard PHP object property, but rather a meta property that further clarifies the value of this field.

  • raw()Mixed

    Retrieve the raw unprocessed value of the field.

  • set_index()Integer

    Retrieve the current set index for this field.

  • set_value( Mixed $value )Mixed

    Sets the value of the field.

  • update()

    Updates the database with with any changes made by any methods that can update the field, which are: val, value, prop, __set.

  • val( $value = null )Mixed

    A shorthand synonym for the value method, to retrieve the value of the field.

  • value( $ )Mixed

    Returns the value of the field, as determined by the field type.Important: the _toString PHP magic method handles direct echoing of field values out to your templates by simply echoing the a MEOW_Field object directly, but this automatic conversion to a string does NOT happen when using the value of a field as a variable in an expression.

Delegate Methods

This class delegates to the MPFT class, meaning it also supports the methods available in that class.

Base Class Methods

View method list from the base class WOOF_Collection.

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